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.
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 ...