Are there any standard tools, or recommended approaches for async tasks execution?
UPD I understand, how to use threads. I only need to know the recommended WPF way
Have a look at below post, it describes a way to create an async delegate command(using BackgroundWorker
). I have used this kind of command in our application and it works fine and at the same time it provides a consistent way of doing things asynchronously.
An Asynchronous Delegate Command for your WPF MVVM Apps - AsyncDelegateCommand http://amazedsaint.blogspot.com/2010/10/asynchronous-delegate-command-for-your.html
A similar implementation is also mentioned here - Asynchronous WPF Commands
You can use several ways, for example:
And since .NET 4, the preferred way is to use Tasks
.
In addition to standard threads. One thing to use are Async methods of many classes, that can do it. This includes web service requests, file read/write operations.
One thing to look at is Coroutines, used mainly by Caliburn.Micro . But its not standard way to do it.
Also .NET 4 adds Task class along with ParallelExtensions, that is capable to do some async programming easier. But its still clumsy, so .NET 5 adds async programing model, to make thigs even easier. But god knows when its going to be released.
depends what you are trying to do async. e.g. calling a WCF service I'd use the build-in way, with the Completed pattern that does the marshalling for you. Normal Background work I'd use the BackgroundWorker as you again don't need to worry about the marshalling.