O'Reilly logo

C# Multithreaded and Parallel Programming by Rodney Ringler

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

Exploring tasks

The Task class represents some work that can be done atomically in an asynchronous manner. It is an item of work executed and managed on the ThreadPool by the TPL. It is very similar to a thread but with a higher level of abstraction and functionality built around it. It is the central control of the Task Parallel Library.

The Task class has a complete set of methods for status updates, cancelation, exception handling, scheduling, and waiting that allows it to be "lightweight" compared to the thread. It can also make more efficient use of system resources given the functionality that the TPL provides to manage the ThreadPool behind the scenes.

Let's start by creating and executing a task. First, we will create a couple of methods ...

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