Task Parallel Library Overview
We can’t expect our sequential program to run faster on the new processors as we know the processor technology advances means the focus is on Multicore-processors. Today’s desktop typically has 4 cores but the latest experimental multi-core chips have up to 1000 cores. In this article, I will give you an overview of Task Parallel Library (TPL) in C#.
So in the simple word, we can say that the multicore processor machines are now becoming standard and the aim is to improve the performance by running a program on multiple processors in parallel.
So by considering the above scenario, the .NET Framework 4 introduces Task Parallel Library (TPL) that makes it easier for developers to write parallel programs that target multi-core machines (automatically use multiple processors) which improve the performance.
Using the Task Parallel Library (TPL), we can express the parallelism in the existing sequential code, means we can express the code as the Parallel task, will be run concurrently on all the available processors.
What is Parallel Programming?
The Parallel Programming is a type of programming in which many calculations or the execution of processes are carried out simultaneously.
Points to Remember while working with Parallel Programming:
- The Tasks must be independent.
- Order of the execution does not matter
C# supports two types of parallelism:
In case of Data Parallelism, the operation is applied to each element of a collection. Means each process does the same work on unique and independent pieces of data.
In case of Task Parallelism independent computations are executed in parallel. Means each process performs a different function or executes different code sections that are independent.
In the next article, I will discuss the Parallel For method in C# with some examples.
In this article, I try to explain the Task Parallel Library (TPL) overview. I hope this article will help you with your need. I would like to have your feedback. Please post your feedback, question, or comments about this article.