FAQ Database Discussion Community


Selectize.js load callback pass-through to custom function

javascript,jquery,asynchronous,callback,selectize.js
I have configured selectize.js to gather configuration options from html data attributes. One of my configuration types is the ability to specify a js function to call for custom data loading (outside simple ajax loading). The code is working well, until I run a custom function that is asynchronous. With...

Dynamically-Allocated Implementation-Class std::async-ing its Member

multithreading,c++11,asynchronous,design,shared-ptr
Consider an operation with a standard asynchronous interface: std::future<void> op(); Internally, op needs to perform a (variable) number of asynchronous operations to complete; the number of these operations is finite but unbounded, and depends on the results of the previous asynchronous operations. Here's a (bad) attempt: /* An object of...

ElasticSearch asynchronous post

database,post,asynchronous,elasticsearch,get
I'm posting data on my ElasticSearch database. I've noticed that data is not immediately available, it requires some milliseconds to show up in a GET request. I can live with that (after all, the calls are asynchronous so this behavior is expected) but in my test code I need to...

Play Scala Converting sync to async

multithreading,scala,asynchronous,playframework
I've been trying to run an Action combined with Action async. I want to know how to run a separate async thread to retrieve some data from the server, and do a redirect or badrequest based off of that result asynchronously. Right now I have to send out a status...

PhantomJS javascript wait until function complete

javascript,asynchronous,phantomjs,wait
I have a problem with a PhantomJS script. The script gets a JSON encoded string from a web page and does other things with it. The script: var address = address; var amount = 0; function changeAmount() { var page=require('webpage').create(); page.open (address, function(){ //parse json, set amount to something (usually...

C++ Ubuntu select() if serial interface has data on asynchronous read

c++,multithreading,ubuntu,asynchronous,serial-port
I´m writing an asynchronous serial data reader class for Ubuntu using C++ and termios and I´m facing difficulties checking is there is data available. Here is my code: #include <iostream> #include <string> #include <sstream> #include <vector> #include <stdio.h> #include <fcntl.h> #include <unistd.h> #include <termios.h> class MySerialClass { public: MySerialClass(std::string port);...

Running promises in small concurrent batches (no more than X at a time)

javascript,node.js,asynchronous,promise,bluebird
The Async library has functions like eachLimit which can be used to efficiently spread a big batch of jobs over multiple CPU cores, like this: var numCPUs = require('os').cpus().length; var exec = require('child_process').exec; async.eachLimit(someArray, numCPUs, function (value, done) { exec('something --input' + value, done); }, finalCallback); This avoids overloading the...

ftp client with async javascript

javascript,node.js,asynchronous,ftp,ftp-client
I'm writing in node.js and using async.js and ftp client modules. I'm using async.series and that is a function in async.series: var client = new ftp(); client.on('ready', function () { for ( var i = 0 ; i < stage._sub_directories.length ; i++ ) { var path = get_absolute_path() + DIRECTORY_NAME_LESSONS...

What is the purpose of boost mpi request's m_handler

c++,asynchronous,boost,request,mpi
I am trying to test an mpi request if it is done or not. However, there is a problem that I could not figure out. If I use test_all method as below, then I see that request is not done. string msg; boost::mpi::request req = world->irecv(some_rank, 0, msg); vector<boost::mpi::request> waitingRequests;...

Asynchronous MVVM commands

wpf,asynchronous,mvvm,async-await,task-parallel-library
I have been following the rather excellent series of articles by Stephen Cleary in the MSDN magazine (Patterns for Asynchronous MVVM Applications) and have been using his IAsyncCommand pattern in a "hello world" style application. However, one area that he does not address is when one needs to pass in...

Using the result of an async method

c#,asynchronous,async-await
I have a simple async method with the signature: public async Task<bool> AllowAccessAsync(string authenticatedUserToken) When calling this method, I appear to have two options when assigning its result to a local variable: bool response = null; // option 1 await this.transportService.AllowAccessAsync(authenticatedUserToken).ContinueWith(task => response = task.Result); // option 2 response =...

How to read multiple csv files in node.js

javascript,node.js,file,csv,asynchronous
I'm trying to read multiple csv files and then add them as properties to an object, but the async of node.js really prevents me from doing this. This is the code I tried. var Converter=require("csvtojson").core.Converter; var fs = require('fs'); var csvConverter=new Converter(); var data = {}; for (var i =...

How to do asynchronous initialization in a RequireJS module

javascript,asynchronous,requirejs
I'm trying to create a module which need needs to fetch data from a URL before initialization is complete. I suspect I am missing something obvious but how to a make RequireJS wait until my async call is complete before the require call is satisifed. // data module (function() {...

Play Scala 2.4 linking asynchronous calls

scala,asynchronous,playframework,playframework-2.0
I'm trying to figure out how to link multiple asynchronous calls and return a result. I am currently trying to asynchronously user data first, and update user data asynchronously and return result, but it seems like it is not working :( i used map { result => Ok(result)}, but play...

Why is the task is not cancelled when I call CancellationTokenSource's Cancel method in async method?

c#,asynchronous,task,cancellationtokensource,cancellation-token
I created a small wrapper around CancellationToken and CancellationTokenSource. The problem I have is that the CancelAsync method of CancellationHelper doesn't work as expected. I'm experiencing the problem with the ItShouldThrowAExceptionButStallsInstead method. To cancel the running task, it calls await coordinator.CancelAsync();, but the task is not cancelled actually and doesn't...

How to convert this JSON to a datatable?

c#,.net,json,asynchronous,json.net
[ [ "<div id=\"status\" style=\"width:20px; height:20px; \" class=\"circle red\"></div>", "<a runat=\"server\" id=\"link0\" href=\"MachineDetails.aspx?PageName=PCsByLocation.aspx&MachineName=AUBDW012\">AUBDW012</>", "Dye, Paul", "", "AsiaPacific / Australia / BrisbaneDistribution", "<div id=\"divonoffswitch\" class=\"onoffswitch\"><input type=\"checkbox\" name=\"onoffswitch\"...

Fire off an event when async javascript is loaded

javascript,events,asynchronous,onload
I'm changing my external javascript resources to be loaded asynchronously to speed up page load. To do this, I'm adding the async property to my script tags: <script async type="text/javascript" src="external.js"></script> Right before the end of the body tag I have included this code to perform callbacks: if (typeof(myFuncion) ===...

What is the preferred AngularJS way of adding CSS styling after Controller asynchronous call?

javascript,angularjs,asynchronous,node-webkit,nw.js
I am building an application with NW.js and AngularJS GitHub Link My application retrieves file names from local folders and displays these filenames in the application as a list. I want the first item in the list look different from the rest because it starts as the "selected" button/item. The...

F# task parallelism under mono doesn't “appear” to execute in parallel

asynchronous,f#,mono,task-parallel-library
I have the following dummy code to test out TPL in F#. (Mono 4.5, xmarin studio, quard core macbook pri) To my surprise, all the processes are done on the same thread. there is not parallelism at all. open System open System.Threading open System.Threading.Tasks let doWork (num:int) (taskId:int) : unit...

Call Sync method call from Async Callback?

c#,asynchronous,synchronous
What happens when a synchronous method is called within an asynchronous callback? Example: private void AcceptCallback(IAsyncResult AR) { tcp.BeginReceive(ReceiveCallback); } private void ReceiveCallback(IAsyncResult AR) { tcp.Send(data); } A connection is accepted and the async receive callback is started. When the tcp connection receives data, it calls the receive callback. If...

Run a loop over a callback, node js

javascript,node.js,asynchronous
I need to resize some images. Problem is the library I'm using do one resize per callback. I want to resize several images so I put it in a loop: exports.resizeImages = function (req, res) { var images = fs.readdirSync('uploads/'); for (var n = 0; n < files.length; n++) {...

GCD Implementation not working with PARSE Query (Swift)

ios,swift,asynchronous,parse.com,grand-central-dispatch
I've looked all over Stack Overflow and other web resources on how to handle the async PARSE query and storing this data into an array. I then use this array to populate a table in another view controller. Code structure is as follows: AppController.swift: public var BuisnessNames = [NSString]()...

Chaining Asynchronous Functions Node.js bluebird mongoskin

javascript,node.js,asynchronous,promise,bluebird
I have been reading many posts on how to chain asynchronous functions but I just can't seem to get it right! As the title indicates. I am trying to chain mongoskin database calls together, so that i can gather all the information in chunks and then finally send the accumulated...

AngularJS - Wait for View HTML to Load Before Executing Variable Assignment?

angularjs,asynchronous
I have a page in AngularJS that looks like <body ng-controller="mainController"> <my-view></my-view> </body> Inside the my-view file, I have an input element: <div> <input id="my-input" type="file"> </div> In my mainController, I assign the file input element to a $scope variable. In about 50% of page loads, the $scope variable is...

Using ConfigureAwait(false) on tasks passed in to Task.WhenAll() fails

c#,asynchronous,async-await
I'm trying to decide how to wait on all async tasks to complete. Here is the code I currently have [HttpGet] public async Task<JsonResult> doAsyncStuff() { var t1 = this.service1.task1(); var t2 = this.service2.task2(); var t3 = this.service3.task3(); var t4 = this.service4.task4(); await Task.WhenAll(t1,t2,t3,t4); return this.Json(new {redirect = true, href...

Node.js - method is returning UNDEFINED when parsing XML

javascript,xml,node.js,asynchronous
I'm parsing a hardcoded XML-structure inside a class in Node.js. The problem is that the parsing is done asynchronously, which causes the method to return the default value (null). function Codeorder() { // Hardcodet XML-tree as string this.order = " <root> \ <order instancename=\"flashlibraries\" opens=\"true\" />\ <order instancename=\"TESTTEST\" opens=\"true\" />\...

Calling a function from outside of require which is written inside of require in dojo

javascript,html,asynchronous,dojo
<html> <head> <script> require(["dojo/ready"],function(ready){ function init(dataItem) { alert("inside init method") updateData(dataItem); } function updateData(dataItem){ //inside this function, i am creating some breadcrumb and making each part of it a link. //Now that link is calling another method outerFunction() } ready(function(){ init({ type: "All Locations", id: "All_Locations" }); }); }); function...

Return from asynchronous request in for loop

multithreading,swift,for-loop,asynchronous
I’m trying to get data from my RestAPI, specifically i’m getting an array of integers (which are id’s from other users), i want to loop through this array and download the data from all the other customers. A simplified version of the code is show below. func asyncFunc(completion: (something:[Int])->Void){ //Get...

SDWebImage Library - placeholder from URL

ios,image,uitableview,asynchronous,sdwebimage
I'm using SDWebImage to download and cache images in an UITableView asynchronously but I'm having some problems. The scenario is the following: When the cell is created I want to load a low quality blurred image (1-2kb) from an URL, before the real image comes in. After the higher quality...

Line by line execution for javascript object

javascript,asynchronous,line-by-line
I am trying to validate an image URL if it exists or not using JavaScript. Basically I want to assign the URL to image if its valid. But the JavaScript function which validates the URL, as not executing line-by-line, disrupts the logic and returns all URLs to be true. Is...

Dynamically build table after it recieves information from service

javascript,html,angularjs,asynchronous,angularjs-directive
HTML Code: <table class="table table-bordered table-striped"> <thead> <tr> <td>one</td> <td>two</td> <td>three</td> </tr> </thead> <tbody> <tr ng-repeat="color in colors"> <td>{{ color.one }}</td> <td>{{ color.two }}</td> <td>{{ color.three }}</td> </tr> </tbody> </table> Controller: var SomeController = function ($scope, SomeService, $window) { var colors= []; SomeService.someFunction().success(function...

.Net Task class - please explain

c#,.net,asynchronous,async-await,task
Can someone please explain why the public async Task DoStuff() method below can still work without returning anything? It doesn't say void, so I assumed the return type would have to be Task. When I remove the async and await keywords from the DoStuff() method, the compiler gives me a...

How to respond to multiple bookmark operations in Chrome?

javascript,google-chrome,asynchronous,google-chrome-extension,bookmarks
I'm working on a simple Chrome extension which deals with bookmarks. So far I've discovered two ways to respond to operations that the chrome.bookmarks API provides: pass callback function directly to the API call (eg. chrome.bookmarks.move(string id, object destination, function callback)) register callback function globally (chrome.bookmarks.onMoved.addListener(function callback)) As far as...

NSIS: Make async web request with query string

http,asynchronous,nsis,sendasynchronousrequest
How do I make an asynchronous GET request to URL like http://www.example.com/somepage?param1=val1&param2=val2 in NSIS. I don;t care about response - all I want is make a request and disregard response (so not for downloading files). Currently I use inetc plugin, however it is less than optimal for 2 reasons: It...

What is the best way to make two web pages communicate between each other back and forth? [closed]

javascript,asynchronous,web
What is the best way to make two web pages communicate between each other back and forth? I will be using HTML and Javascript. Basically I want to login on a web page and I should be able to see who has logged in from the second page. It's just...

How would “this” behave normally within nested async module functions? [duplicate]

javascript,node.js,asynchronous,sails.js
This question already has an answer here: How does the “this” keyword work? 11 answers I'm using Sails.js framework and its great Model's feature, also I'm using the async version it uses as its dependency. So, in order of explaining a practical scenario: get all comments on songs sung...

Telerik Report Viewer don't work with jquery async: false

jquery,asp.net-mvc,asynchronous,telerik-reporting
I am using jQuery 1.11.0 in my project. I have changed ajaxSetting. I did async:!0 instead of async:!1 because my remote validation was working unexpectedly. This change didn't bother me anywhere but in Telerik Reporting. Due to this change Telerik Reporting don't load. Is there anything I do any telerik...

await/async odd behaviour

c#,.net,asynchronous,async-await,task-parallel-library
I have a simple Console Application using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { public class Program { static void Main(string[] args) { MockAPI api = new MockAPI(); Task t = api.GetVersion(); var placeBreakPoint = "breakpoint"; } } public class MockAPI { public async Task<string>...

run oncomplete event in async

c#,multithreading,asynchronous
Is there someway of letting an oncomplete event run in Async. The oncomplete event is called from an external dll. The external dll uses Async and I am creating a wrapper for it that hides multithreading. I Have tried using AutoResetEvents but these get stuck on the WaitOne as the...

MVVM How to set datacontext when viewmodel uses async

c#,asynchronous,mvvm,windows-phone-8.1
After hours of searching I am still without answer to this question. I have read this nice writing about async MVVM and made my viewmodel to use factory method. public class MainViewModel { public MainViewModel() { } private async Task InitializeAsync() { await DoSomethingAsync(); } public static async Task<MainViewModel> CreateAsync()...

How to rewrite simple if-then from synchronous to asynchronous?

ajax,asynchronous
I have this code: if (condition) { syncAjax(); } callAfterAjaxOnlyOnce(); and I want to rewrite to asyncAjax(). But this is not okay if (condition) { asyncAjax(callback(){callAfterAjaxOnlyOnce();}); } when condition is false because callAfterAjaxOnlyOnce() will be executed 0 time. This is also not good if (condition) { asyncAjax(callback(){callAfterAjaxOnlyOnce();}); } callAfterAjaxOnlyOnce(); when...

Use async/await with Microsoft.Bcl.Async: the type or namespace name 'async' could not be found

c#,asp.net,asynchronous,.net-4.0
I need to use async/await on the .net framework 4, VS2013 (web forms application). I installed Microsoft.Bcl.Async via nuget, but I get always: The type or namespace name 'async' could not be found And if I try to define a namespace like: using Microsoft.Threading.Tasks; I get The type or namespace...

Contexts and callbacks from asynchronous tasks

android,android-fragments,asynchronous
I've been experiencing this problem on some devices, especially Samsung. I have an activity that has 7 fragments. In most of them, I start an async task for getting some data. I handle the exceptions by creating a handler in onCreateView(). handler = new Handler(new Handler.Callback() { @Override public boolean...

Does Ruby support nonblocking HTTP requests without a third-party library?

ruby,http,asynchronous,gem,eventmachine
I am writing an API to access resources on one of my servers. Part of this API will make HTTP requests. In the name of good software design, I don't want my API to be blocking. I am fairly new to Ruby, but in Java I would provide an Asynchronous...

Using Q.js promise for unit-tests: timeout of 2000ms exceeded

javascript,unit-testing,asynchronous,mocha,q
I'm using Q.js library for simulating async behaviour by using promise I have a stubed backend api class ApiStub { constructor(){ this.deferred = Q.defer(); } post(url, data) { if (data) { this.deferred.resolve(data); } else { this.deferred.reject(new Error("Invalid data")); } return this.deferred.promise; } } and I'm trying to test it: before(()...

Update the todo list without refreshing the page in express nodejs app

javascript,node.js,asynchronous,express,mean-stack
I am a newbee to the express nodejs applications. I want to make a todo list. This is how it looks so far. My question is when I add a todo, it takes some time to show the change since it reloads the page. How can I see the change...

C# async await simple issue

c#,asynchronous,async-await
I'm just learning about task, and async/await implementation and I'm struggling with a simple code example so I was hoping someone could share some lights as to what is going on. here's the code: public async Task<string> DoStuff() { Console.WriteLine("Long running op started"); var myString = await Task<string>.Run(() => {...

How to create a Task from already asynchronous code?

c#,asynchronous,task-parallel-library
I have some code that's already asynchronous - just not using the Task system. I would like to make it a lightweight Task, if possible, so that code may leverage it as a Task. So I want to take this: void BeginThing(Action callback); And turn it into this pseudocode: Task...

How many Async calls we can call in one request in Google App Engine

google-app-engine,asynchronous
I'm writing an app on top of google app engine. Using Java as language. I'm new to GAE. I want to use URL fetch service for async calls in application. I'm having few doubts 1. How many async calls I can call in one appengine request ? 2. What happens...

Task await fails

c#,asynchronous,async-await,signalr,task
I am starting a HubConnection. First I get a new Instance of HubConnection, afterwards I create a new IHubProxy with Name = "fileHub" so far so good. My problem is located at (or in) the awaitable Function ContinueWith, I try to start the Connection, and write to the console wheater...

Consecutive and sequence insert in node.js sqlite

node.js,asynchronous,sqlite3,event-handling
my code is: var json = [1,2,3,4,5,6,7,8,9]; async.forEach(json, function (that, callback) { sqlitedb.run("INSERT INTO mytable (name) VALUES ("+that+")" , function () { console.log(that); callback(); }); }); The callback() placed on after insert item. but when i execute, my json items inserted on no squence and result is like: 7 8...

sapui5 component settings shown sometimes, sometimes undefined (same code)

javascript,asynchronous,sapui5
I want to use the same SAPUI5 component for different uses. I want to differentiate between the uses with settings, as shown here var oComponentContainer = new sap.ui.core.ComponentContainer( { url : "resources/components/clientSelector", name : "components.clientSelector", id : "components.clientSelector", propagateModel : true, settings : { bPopupView : true, iOffset : $(document).height()...

Why does the method return a string when return type is Task?

c#,.net,asynchronous,async-await
I have a question about asynchronous programming in C#. I want to know why a function that has a return type of Task has to return a string. So even through I returned a string, it gets wrapped into a Task again - why is that? Problem is that I...

async.parallel inside async.series

node.js,asynchronous
I have this async.parallel functionality inside an aysnc.eachSeries call. I hardcoded an error so I could pass it, to see if it was behaving the way I thought. For some reason, when I pass an error, it doesn't get thrown in the final callback named "doneWithSeries". async.eachSeries(jsonDataArr, function iterator(item, callback)...

chrome.storage.sync.get sync with outer level object, but inner object is not sync?

javascript,google-chrome,asynchronous,sync
I am trying to use chrome.storage.sync.get to get back the settings. What I don't understand is that when I call console.log(settings), it returns the correct values. But if I call console.log(settings.speeds), it returns the old values. I think this has something to do with the async nature of chrome.storage.sync.get. Can...

ZeroMQ pattern for multiple asynchronous requests to single endpoint

sockets,asynchronous,zeromq
I'm using zmq to develop a distributed application having the following network topology: a client node that initiates a request and a server node that replies to requests. Since the client is a node.js application I can't block after a send call to wait the response, so the scenario is...

Why can an Exception not be rethrown in the BackgroundWorker RunWorkerCompleted event

c#,asynchronous,exception-handling,backgroundworker
I've checked through some posts on this topic which cover how to get around this issues, but I can't quite understand the Why of this odd behaviour? Short version: Why is are Exceptions thrown inside the RunWorkerCompleted event not caught by the calling code? Detailed version: I have a BackgroundWorker...

async.each cannot set headers after already set

javascript,asynchronous,express
Here's what happening. I'm saving new companies first, then attaching the _id to each new user before they get saved. The issue I'm running into is returning a response. When I put the res.json() into the function thats getting repeated obviously I'm getting an error because I already have a...

AngularJs factory function undefined in controller

angularjs,asynchronous,angularjs-service,angularjs-controller,angularjs-factory
I used to make it work the exact same way before, and it's driving me crazy. I want to perform a $http GET call into a factory and then get back the result into the controller, to be processed. The factory (don't pay attention to the madness of the request...

Correct way to convert method to async in C#?

c#,asynchronous,async-await
I'm attempting to convert the following method (simplified example) to be asynchronous, as the cacheMissResolver call may be expensive in terms of time (database lookup, network call): // Synchronous version public class ThingCache { private static readonly object _lockObj; // ... other stuff public Thing Get(string key, Func<Thing> cacheMissResolver) {...

async methods in callbacks

c#,windows,asynchronous,phone
I'm new to Windows Phone programming and I'm having some problems. What I'm trying to do is make a background task that logs each unlock of the Phone but I can't get the writing to the log to work. This is what how I'm registering a background Task: public App()...

Tornado and concurrent.futures.Executor

asynchronous,tornado,future
I'm learning about async and Torando and struggling. First off is it possible to use executor class in Tornado? The below example i'm creating a websocket and when receiving a message I want to run check() as another process in the background. This is a contrived example just for my...

WSARecv() and multiple buffers

c++,c,sockets,asynchronous,winsock2
I would like a precision with WSARecv. Basically it seems you can use the function with an array of WSABUFs. 1- In an overlapped I/O context WITHOUT completion ports, say I use WSARecv() on a datagram socket with an array of 48 WSABUFs, does it means I can receive 48...

Async Function in Vala - Yield & Callback

function,asynchronous,gtk,vala
I'm developing a project written in Vala and GTK +, I need to implement an asynchronous function, therefore I set out to make an example of test ... and for some reason I get the following error: async.vala:31.3-31.20: error: Access to async callback `asyncProc.callback' not allowed in this context asyncProc.callback...

async js callback for each upload

javascript,asynchronous,callback,angular-file-upload
I'm new at web develop. I was faced with the following problem: I upload images at amazon s3 and getting callback with response which contains link to this image. Then I push it into array and store this array in DB. But I don't know how to go to the...

Is grunt.file.write(…) synchronous or asynchronous?

javascript,node.js,asynchronous,gruntjs
I have a code in which i am running a grunt task asynchronously using var done = this.async(); Somewhere in the code I am writing to a file and then calling a callback as follows: grunt.fie.write(<necessary arguments>); callback(null); My question is, will there be a case in which the callback...

Call method after asynchronous request obj-c

ios,objective-c,asynchronous,uiviewcontroller,nsobject
In my app I init a new object, where there is method which calls NSURLConnection's sendAsynchronousRequest method. After the request, I would like to call a method in the caller UIViewController. I tried to use a static method but I then I can't control IBOutlets. How can I do this?...

Why async code is run on worker thread in C#

c#,multithreading,asynchronous,async-await
I am playing with the async/await in the C# and while I think that I understand most of the concepts, I can not explain why the code line "var rxres = await ..." first time runs on my UDP thread, and after further receptions of the packets runs on the...

Exception in async task gets intercepted in Visual Studio

c#,visual-studio,exception,asynchronous
I want to run several tasks, some of which would complete async'ly, and then wait for all of them to complete. As the tasks may throw exceptions, I want to catch and log them. sample code for that: static async Task doit(int x) { try { Console.WriteLine("{0} {1} start", x,...

Calling a parse function asynchronously

android,asynchronous,parse.com,parse-android-sdk
I have to fetch some data from the parse cloud. I'm using the parse sdk for android. How do I call the method findInBackground asynchronously in my activity? Essentially, where do I place this piece of code in my Activity? Below is my code: ParseQuery<ParseObject> query = ParseQuery.getQuery("Average"); query.whereEqualTo("squarefeet", area);...

Asynchronous TADOQuery's OnFetchComplete not synchonized to main thread

delphi,asynchronous,delphi-xe4,delphi-xe8,tadoquery
When using TADOQuery with [eoAsyncFetchNonBlocking] and attaching to OnFetchComplete event I found that OnFetchComplete is not executing in the main thread (tested in XE4 and XE8). I assume this a bug*, since most of us will do work in the UI on these type of event. I believe this to...

Recursive Asynchronous calls with TPL/ async await

c#,.net,multithreading,asynchronous,recursion
I am looking at processing a hierarchical structure in a recursive fashion using C# asynchronous features (TPL/ async/await). Here is an overview of what I am trying to do I have a jobs collection to process as shown below. Each Job has something to do and optionally can have one...

Why is asynchronous network testing difficult in Objective-C/Swift?

ios,swift,asynchronous,concurrency,grand-central-dispatch
So I'm learning more about how to test asynchronous code when I come across the following: As soon as a given test method completes, XCTest methods will consider a test to be finished and move onto the next test. That means that any asynchronous code from the previous test will...

Would async/await provide benefit over Task for intertwined statements?

c#,.net,asynchronous,async-await,task-parallel-library
I have a method (called via an AJAX request) that runs at the end of a sequence. In this method I save to the database, send emails, look up a bunch of info in other APIs/databases, correlate things together, etc.. I just refactored the original method into a second revision...

async await for a HttpClient.PostAsync call

c#,asynchronous,async-await,dotnet-httpclient
I'm trying to wrap a call to PostAsync so I don't have to recode the call sequence all over my code base. The issue I'm having is the HttpResponseMessage I assigned from the call is not the same as the one the consumer of my method calls. Here is the...

Why my image is not display immediately after downloaded?

swift,asynchronous,uiscrollview
I am having problem with async programming.I have a UIScrollView which will display multiple images(3~10) when I enter into detail view.So,there are two process that I currently working on.First,When I enter to the detail view,the post request which will call api to display detail data(images and data).Second,when I get the...

Java run async processes

java,multithreading,asynchronous,process,processbuilder
I am trying to run an async process and I do not want the program to wait until the end of these processes executions. I found this question how to run shell script asynchronously from within Java program but it doesn't have the answer that I am looking for. What...

How to use the Akka ask pattern without blocking

scala,asynchronous,akka,future
Hi I have a actor which is responsible for fetching data from a database, turning it into a list and sending it back to the sender. I am using the ask pattern to receive response from my actor, because I don't want to use await.result because this approach will block...

Async GetMany method in Repository

c#,asynchronous,collections
I have repository method which returns collection according to filter public IEnumerable<T> GetMany(Expression<Func<T, bool>> filter = null) { IQueryable<T> query = DbSet; if (filter != null) { query = query.Where(filter); } return query.ToList(); } Now i want to write this method as Async. And this is my problem. Should i...

React/reflux how to do proper async calls

javascript,asynchronous,reactjs,jsx,refluxjs
I recently started to learn ReactJS, but I'm getting confused for async calls. Lets say I have a Login page with user/pass fields and login button. Component looks like: var Login = React.createClass({ getInitialState: function() { return { isLoggedIn: AuthStore.isLoggedIn() }; }, onLoginChange: function(loginState) { this.setState({ isLoggedIn: loginState }); },...

Get file name from stats object

javascript,node.js,asynchronous
I use the fs.stat for getting information about file, now I want to get the file name from the stats object, I did some searching and I didnt find anything help. I will explain my code now, maybe someone will find another solution, this is all my code: function index(response,...

node async is not runned async [duplicate]

javascript,node.js,asynchronous
This question already has an answer here: How to return the response from an asynchronous call? 7 answers I am trying to use async to collect some additional data to my array. for this purpose ive created the following: User_has_academy_module.findAll({ include: [{model: Module, include: [Category, ModuleType]}], where: {academy_team_id: team_id,...

FastDOM - Read / write every 17ms?

javascript,dom,optimization,asynchronous,requestanimationframe
FastDOM - a small library that batches DOM reads & writes into raf (requestAnimationFrames). https://github.com/wilsonpage/fastdom I have read the code, however, I am struggling to understand how it works. Here are a few presumptions we have: - Browsers are generally set to 60fps - So in total, there can be...

Bulkheading strategies for Akka actors

java,asynchronous,akka,blocking,future
I have a scenario where an important actor needs to make a call to a slow (15 - 20 seconds) remote system: // Non-actor code equivalent public Result makeSlowNetworkCall(Request request) { Result result = slowServiceClient.soooooSlow(request); // Could be up to 15 - 20 SECONDS (mehhhh) return result; } The Akka...

How should I execute functions only one after another in JavaScript?

javascript,asynchronous,synchronous
I am trying to make a time conversion tool, first thing it does is gets the co-ordinates of both the cities you enter and then calculates time accordingly. But the problem I am facing is that the function which gets the co-ordinates takes some time and it is asynchronous as...

Async await usage for MongoDB repository

c#,mongodb,asynchronous,parallel-processing,async-await
I have a MongoDB repository class as you see below: public class MongoDbRepository<TEntity> : IRepository<TEntity> where TEntity : EntityBase { private IMongoClient client; private IMongoDatabase database; private IMongoCollection<TEntity> collection; public MongoDbRepository() { client = new MongoClient(); database = client.GetDatabase("Test"); collection = database.GetCollection<TEntity>(typeof(TEntity).Name); } public async Task Insert(TEntity entity) { if...

Use Asynchronous IO better

javascript,node.js,asynchronous,papaparse
I am really new to JS, and even newer to node.js. So using "traditional" programming paradigms my file looks like this: var d = require('babyparse'); var fs = require('fs'); var file = fs.readFile('SkuDetail.txt'); d.parse(file); So this has many problems: It's not asynchronous My file is bigger than the default max...

Asynchronously manipulating data from streamReader in F#

asynchronous,f#,streamreader
On the line of Read large txt file multithreaded?, I have the doubt of whether it is equivalent to pass to each thread an sliced chunk of a Seq and whether it will safely handle the paralellism; is it StreamReader thread-safe? Here is the code I am using to test...

cancel task.delay without exception or use exeption to controll flow?

c#,asynchronous,exception-handling,async-await,task-parallel-library
I'm unsure about two possibilities to react to an event in my code. Mostly I'm concerned about which one needs less resources. I have a method with an observer registered to an eventproducer. If the eventproducer returns something, the method exits and the caller of the method starts the method...

Using RoboSpice for asynchronus threading

android,multithreading,asynchronous,robospice
I am trying to use RoboSpice for my Android app but I am getting very confused with the documentation. Basically, I would like to implement only an asynchronous service in the background of the app which does not get destroyed when the activity is changed etc for a thread that...

Swift closures [weak self] and async tasks

ios,swift,asynchronous,closures
Imagine a situation, when you want to asynchronously load some text from the server and display the result in the ViewController's UITextField. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { //... some long running async operation if let textResponse = responseFromServer { dispatch_async(dispatch_get_main_queue(), { [weak self] () in self?.textField.text = textResponse }) } }) A.)...

How to wait for a return value from an event handler without blocking main UI thread

c#,multithreading,asynchronous,xamarin,event-handling
So I have this method this uses a library to generate an external webpage to allow the user to enter their Facebook credentials for verification. Upon entering it we are creating a profile based on the that user's account and saving it to a database. Once we save it to...

node.js continues execution without waiting for a require to complete.

node.js,asynchronous,requirejs
I'm trying to access a variable in a required node file. However the file requiring it always continues without waiting for the variable to be set. How do I get app.coffee to wait before continuing? I have two files: db.coffee: databaseUrl = 'mongodb://localhost/db' mongoose = require('mongoose') mongoose.connect(databaseUrl) db = mongoose.connection...

Windows Phone 8.1 Showing progress view until async/await task finishes

c#,asynchronous,windows-phone-8.1,win-universal-app
I have two tasks which download an mp3 from web address inside local storage and returns timeSpan. public async Task<TimeSpan> filedownload_Ignition_Outside() { Uri sourceIgnition_Outside = new Uri(TemporaryAddress.download_playCarSound+"Ignition_Outside"); //download and store file return duration_Ignition_Outside; } public async Task<TimeSpan> filedownload_Idle_Outside() { Uri sourceIdle_Outside = new Uri(TemporaryAddress.download_playCarSound +"Idle_Outside"); StorageFile destinationFileIdle_Outside; //download and store...

JavaScript Arrays with Async Functions

javascript,arrays,asynchronous
I have an array of strings in JavaScript. The array is defined like the following: var myArray = []; myArray.push('1'); myArray.push('2'); myArray.push('3'); I need to loop through the array and call a function that runs asynchronously. That function looks like this: function myAsyncFunction(id, callback) { $.ajax({ url: '/api/items', data: {...

Async HTTP response is holding some seconds after finish the request

ios,asynchronous
The snippet of code below we ran into issues with a while ago, it is run on a successful Async HTTP response. After the response is received the user is still waiting a few seconds (or longer) before the segue is performed. someService.doAction(input, callback: { self.performSegueWithIdentifier("Some-ID", sender:self) }) why the...

Javascript async skips if-else

javascript,angularjs,asynchronous
I have an if-else block that parses user input before making a http.get() to the server. However, the if-else keeps on being skipped over. I tried rearranging my code to force it to complete the if-else before calling get(), but nothing seems to work. I'm also using AngularJS. //controller function...

How to parallelize many (100+) tasks without hitting global GCD limit?

ios,objective-c,multithreading,asynchronous,grand-central-dispatch
The problem: When lazy-loading a list of 100+ icons in the background, I hit the GCD thread limit (64 threads), which causes my app to freeze up with a semaphore_wait_trap on the main thread. I want to restructure my threading code to prevent this from happening, while still loading the...

Async request does not enter completion block

ios,objective-c,arrays,asynchronous
The following code is an attempt to me better understand [NSURLConnection sendAsynchronousRequest:queue:completionHandler]. There are NSLog statements in the completionHandler block, but when I run this in main.m in XCode from a command line project, it never enters the completionHandler blocks. I've tried using the different queues, mainQueue and currentQueue but...

Merge asyc method into one task

c#,.net,asynchronous,async-await
Not sure if this is possible or if it already does something simpler with chained tasks internally, could not work it out from the info I read. public async Task<ClaimsIdentity> CreateIdentity(string userid ) { Guid gid = Guid.Parse(userid); Avatar avatar = await _dbContext.Users.Where(d => d.Id == gid).FirstOrDefaultAsync(); return await CreateIdentity(avatar);...