WaitAll vs WhenAll

Task.WaitAll blocks the current thread until everything has completed. Task.WhenAll returns a task which represents the action of waiting until everything has completed. That means that from an async method, you can use: await Task.WhenAll(tasks); … which means your method will continue when everything’s completed, but you won’t tie up a thread to just hang … Read more

asynchronous and non-blocking calls? also between blocking and synchronous

In many circumstances they are different names for the same thing, but in some contexts they are quite different. So it depends. Terminology is not applied in a totally consistent way across the whole software industry. For example in the classic sockets API, a non-blocking socket is one that simply returns immediately with a special … Read more

AngularJS : Initialize service with asynchronous data

Have you had a look at $routeProvider.when(‘/path’,{ resolve:{…}? It can make the promise approach a bit cleaner: Expose a promise in your service: app.service(‘MyService’, function($http) { var myData = null; var promise = $http.get(‘data.json’).success(function (data) { myData = data; }); return { promise:promise, setData: function (data) { myData = data; }, doStuff: function () { … Read more

Can’t specify the ‘async’ modifier on the ‘Main’ method of a console app

As you discovered, in VS11 the compiler will disallow an async Main method. This was allowed (but never recommended) in VS2010 with the Async CTP. Update, 2017-11-30: As of Visual Studio 2017 Update 3 (15.3), the language now supports an async Main – as long as it returns Task or Task<T>. So you can now … Read more

How to return value from an asynchronous callback function? [duplicate]

This is impossible as you cannot return from an asynchronous call inside a synchronous method. In this case you need to pass a callback to foo that will receive the return value function foo(address, fn){ geocoder.geocode( { ‘address’: address}, function(results, status) { fn(results[0].geometry.location); }); } foo(“address”, function(location){ alert(location); // this is where you get the … Read more

What are the best use cases for Akka framework [closed]

I have used it so far in two real projects very successfully. both are in the near real-time traffic information field (traffic as in cars on highways), distributed over several nodes, integrating messages between several parties, reliable backend systems. I’m not at liberty to give specifics on clients yet, when I do get the OK … Read more

How would I run an async Task method synchronously?

Here’s a workaround I found that works for all cases (including suspended dispatchers). It’s not my code and I’m still working to fully understand it, but it does work. It can be called using: customerList = AsyncHelpers.RunSync<List<Customer>>(() => GetCustomers()); Code is from here public static class AsyncHelpers { /// <summary> /// Execute’s an async Task<T> … Read more

Call async/await functions in parallel

You can await on Promise.all(): await Promise.all([someCall(), anotherCall()]); To store the results: let [someResult, anotherResult] = await Promise.all([someCall(), anotherCall()]); Note that Promise.all fails fast, which means that as soon as one of the promises supplied to it rejects, then the entire thing rejects. const happy = (v, ms) => new Promise((resolve) => setTimeout(() => resolve(v), … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)