Tasks

Learn to run background jobs with the help of tasks.

Introduction

In addition to the ThreadPool class, there’s another way to use a pool’s threads. With the help of the Task Parallel Library (TPL), we can asynchronously execute methods that we want to run in the background. The TPL library is based on the concept of tasks, each of which describes a separate operation. Tasks are represented by the Task class that resides in the System.Threading.Tasks namespace. This class encapsulates a method that executes asynchronously (without blocking the main thread) on a pool’s thread.

We create ...