Quantcast
Viewing all articles
Browse latest Browse all 10

Using the .NET 4 Task class in WPF

Here’s a quick example on how to implement an asynchronous call in WPF using the System.Threading.Tasks.Task class. Keep in mind that underneath, the call will still end up in a thread pool, as opposed to a ThreadPool approach. [crayon-51dafc64efcd3/] The trick is to use TaskScheduler.FromCurrentSynchronizationContext() to make sure we can work in the UI Thread. ContinueWith sets up a follow-up call to do some final work and that’s it.

Viewing all articles
Browse latest Browse all 10

Trending Articles