Tweaking the execution of tasks with TaskScheduler
This recipe describes another very important aspect of dealing with tasks, which is a proper way to work with a UI from the asynchronous code. You 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.
To step through this recipe, you will need Visual Studio 2015. There are no other prerequisites. The source code for this recipe can be found at
How to do it...
To tweak task execution with
TaskScheduler, perform the following steps:
- Start Visual Studio 2015. 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 ...