BT

Resources On Async Tasks

| by Roopesh Shenoy Follow 0 Followers on Jun 10, 2012. Estimated reading time: 1 minute |

Async Tasks, included in the Task Parallel Library, is a great way to write asynchronous code in – we look at a few resources that show how to use this API in different scenarios and what are the various considerations.

In the article “Enabling Progress And Cancellation in Async APIs” Brandon Bay shows how to create keep a Progress Bar updated while uploading a file asynchronously. You can also use the cancellation token to allow the user to cancel an async task. In an earlier article, Brandon shows the difference between the earlier methods of writing asynchronous code (through EAP and APM) and the new way through async and await keywords. This FAQ on Async/Await also gets into more details and points to more resources. 

While asynchronous programming becomes much simpler with the new key words, developers should avoid going over-board in using them – async calls can be expensive and it is better to make few large async calls over lots of small ones.

Use of Async is not limited to Windows Programming, and it can be used in ASP.NET server-side code as well. Task Support For Async Controllers, introduced in ASP.NET MVC 4, makes it much easier to write non-blocking code in controllers which can further use asynchronous methods themselves. You can even set timeouts and raise exceptions when a timeout does occur. Note though, that this is supported only with C# 5.

It's worth noting, that the async and await keywords are so convenient that at least one node.js fork is already experimenting with the syntax as an alternative to traditional callbacks in javascript.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

No need to branching node.js by Jeffrey Zhao

Jscex get everything you need.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

1 Discuss

Educational Content

BT