The Tasks component defines types that simplify the work of writing concurrent and asynchronous code. It allows developers to be more productive by simplifying the process of adding parallelism and concurrency to applications.

The Tasks component is completely free to use! You can download the component today through our trusted e-commerce partner, FastSpring.

This component handles the partitioning of the work, scheduling of threads, load balancing, state management and other low-level details. The functions included in this component scale dynamically to most efficiently use all available processors.

The Tasks component supports both data and task parallelism through the Parallel class that implements parallel methods for common operations such as for loops and execution of a set of statements. Its parallel for loop is very similar to a sequential loop; you do not have to create threads or queue work items.

Both the Parallel.For and Parallel.Invoke methods have several overloads with specialized parameters. For example, the ParallelOptions parameter lets you request that an operation should stop execution at the system's earliest convenience (through the CancellationToken and ParallelLoopState properties).

Better by Design

  • The other PTL algorithms and containers components are built on top of the Tasks component. You can use the parallel methods available in the algorithms and containers components and safely ignore the Tasks component, or you can use the Tasks component to add parallelism to your own classes.
  • It simplifies multithreaded scenarios because you work at the task level instead of working with threads.
  • It is fine-tuned for various real life scenarios. For example, if a loop performs only a small amount of work on each iteration, you can use the overloaded method that has the specified partition size as an extra parameter. This will tremendously improve the performance of your code.