How can I use the async keywords in a project targeting.net 4.0

You want the Microsoft.Bcl.Async package. That’s a properly released, non-CTP package that is stable. This also requires VS2012 since an updated compiler is needed to understand async and await. In theory one could use older tools from VS2010 along with the older CTP library, I’d strongly recommend that you don’t – it has bugs and … Read more

caching the result from a [n async] factory method iff it doesn’t throw

Does this get anywhere near your requirements? The behaviour falls somewhere between ExecutionAndPublication and PublicationOnly. While the initializer is in-flight all calls to Value will be handed the same task (which is cached temporarily but could subsequently succeed or fail); if the initializer succeeds then that completed task is cached permanently; if the initializer fails … Read more

Promise.all is returning an array of undefined and resolves before being done

Promise.all accepts an Array of Promise objects. You’re getting an Array of undefined because you’re not returning any Promise in your map callback: function addText(queries) { return Promise.all(queries.map(function(query) { // Add `return` here or the `map` returns an Array of `undefined`. return models.queries .findById(query.queryId, { raw: true, attributes: [ “query” ] }) .then(function(queryFetched) { query.text … Read more

Will a chain of method calls (CompletableFuture API) execute asynchronously if the first method in a chain is asynchronous?

OK, so there are 3 types of methods in CompletableFuture. For example: thenApply() thenApplyAsync(Function) (without an Executor) thenApplyAsync(Function, Executor) (with an Executor) The last one means that this action will execute in the Executor that you pass to it and it is the most obvious one. The second one means that the action is executed … Read more

MySQL C# async methods doesn’t work?

Judging from some old code (6.7.2), it appears that the mysql ADO.NET provider does not implement any of the async functionality correctly. This includes the TAP pattern and the older style Begin…, End… async patterns. In that version, the Db* async methods appear to not be written at all; they would be using the base … Read more