Skip to content

Latest commit

 

History

History
42 lines (38 loc) · 3.66 KB

File metadata and controls

42 lines (38 loc) · 3.66 KB
title Task Parallel Library (TPL)
ms.custom
ms.date 03/30/2017
ms.prod .net
ms.reviewer
ms.suite
ms.technology dotnet-standard
ms.tgt_pltfrm
ms.topic article
helpviewer_keywords
.NET, concurrency in
.NET, parallel programming in
Parallel Programming
ms.assetid b8f99f43-9104-45fd-9bff-385a20488a23
caps.latest.revision 37
author rpetrusha
ms.author ronpet
manager wpickett
ms.workload
dotnet
dotnetcore

Task Parallel Library (TPL)

The Task Parallel Library (TPL) is a set of public types and APIs in the xref:System.Threading?displayProperty=nameWithType and xref:System.Threading.Tasks?displayProperty=nameWithType namespaces. The purpose of the TPL is to make developers more productive by simplifying the process of adding parallelism and concurrency to applications. The TPL scales the degree of concurrency dynamically to most efficiently use all the processors that are available. In addition, the TPL handles the partitioning of the work, the scheduling of threads on the xref:System.Threading.ThreadPool, cancellation support, state management, and other low-level details. By using TPL, you can maximize the performance of your code while focusing on the work that your program is designed to accomplish.

Starting with the [!INCLUDEnet_v40_short], the TPL is the preferred way to write multithreaded and parallel code. However, not all code is suitable for parallelization; for example, if a loop performs only a small amount of work on each iteration, or it doesn't run for many iterations, then the overhead of parallelization can cause the code to run more slowly. Furthermore, parallelization like any multithreaded code adds complexity to your program execution. Although the TPL simplifies multithreaded scenarios, we recommend that you have a basic understanding of threading concepts, for example, locks, deadlocks, and race conditions, so that you can use the TPL effectively.

Related Topics

Title Description
Data Parallelism Describes how to create parallel for and foreach loops (For and For Each in Visual Basic).
Task-based Asynchronous Programming Describes how to create and run tasks implicitly by using xref:System.Threading.Tasks.Parallel.Invoke%2A?displayProperty=nameWithType or explicitly by using xref:System.Threading.Tasks.Task objects directly.
Dataflow Describes how to use the dataflow components in the TPL Dataflow Library to handle multiple operations that must communicate with one another or to process data as it becomes available.
Using TPL with Other Asynchronous Patterns Describes how to use TPL with other asynchronous patterns in .NET
Potential Pitfalls in Data and Task Parallelism Describes some common pitfalls and how to avoid them.
Parallel LINQ (PLINQ) Describes how to achieve data parallelism with LINQ queries.
Parallel Programming Top level node for .NET parallel programming.

See Also

Samples for Parallel Programming with the .NET Framework