Home > Uncategorized > welcome async/await, goodbye BackgroundWorker

welcome async/await, goodbye BackgroundWorker

There are a lot of choice for us for doing asynchronous  work in UI. Which one is the best ? Can async/await replace BackgroundWorkder completely

async/await should replace your old BackgroundWorker. That’s it ! Why ?

MSDN explain about this.. Check this out

 

The async-based approach to asynchronous programming is preferable to existing approaches in almost every case. In particular, this approach is better than BackgroundWorker for IO-bound operations because the code is simpler and you don’t have to guard against race conditions. In combination with Task.Run, async programming is better than BackgroundWorker for CPU-bound operations because async programming separates the coordination details of running your code from the work that Task.Run transfers to the threadpool.


Ok. async/await is cool. But how to show the progress with async/await ? Can we do that. We need progress and cancel feature !

image

Of course we can !

You should visit this awesome blog post.

http://blogs.msdn.com/b/dotnet/archive/2012/06/06/async-in-4-5-enabling-progress-and-cancellation-in-async-apis.aspx

 

Cheers

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: