O'Reilly logo

Multithreading in C# 5.0 Cookbook by Eugene Agafonov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Tweaking tasks execution with TaskScheduler

This recipe describes another very important aspect of dealing with tasks, which is a proper way to work with UI from the asynchronous code. We will learn what a task scheduler is, why it is so important, how it can harm our application, and how to use it to avoid errors.

Getting ready

To step through this recipe, you will need Visual Studio 2012. There are no other prerequisites. The source code for this recipe can be found at BookSamples\Chapter4\Recipe9.

How to do it...

For tweaking tasks execution with TaskScheduler, perform the following steps:

  1. Start Visual Studio 2012. Create a new C# WPF Application project. This time we will need a UI thread with a message loop, which is not available in console applications. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required