Introducing tasks and parallels
We know that asynchronous programming helps our application to scale and respond better, so implementing asynchronous applications should not be an overhead for developers. Thread
and ThreadPool
, while helping to achieve asynchronicity, add a lot of overhead and come with limitations. Hence, Microsoft came up with tasks, which make it easier to develop asynchronous applications. In fact, most of the newer APIs in .NET 5 only support the asynchronous way of programming. For example, the Universal Windows Platform (UWP) doesn't even expose APIs to create threads without tasks. As such, having an understanding of tasks and the TPL is fundamental to being able to write asynchronous programs using C#. We will dive deep into these topics in this section and later, we will see how the C# async-await keywords combined with the TPL simplify asynchronous programming.
Introduction to Task and the TPL
The idea behind asynchronous programming is that none...