11

Applied .NET Task Parallel Library

by Jeffrey Juday

It has become a multicore world, and parallel programming must be embraced for a developer to capitalize on all the burgeoning multicore potential. Embracing parallel programming in .NET means a developer must learn about the Task Parallel Library (TPL).

Although .NET has always had features often associated with concurrency and parallel algorithms such as threading and mutexes, the goal of the aTPL is to make concurrency and parallel construction even easier. Borrowing from academia, commercial best practices, and incorporating some unique innovations, the TPL has been assembled to simplify .NET parallel programming. The TPL introduces some new constructs and sports an improved ThreadPooling mechanism.

Parallel programming is often divided into data parallelism and task parallelism. Data parallelism in .NET is encapsulated into parallel loops and parallel LINQ. Underpinning parallel loops and parallel LINQ are all the TPL task parallelism classes. Although a developer could leverage parallel loops and parallel LINQ without delving into all TPL classes, diverging from some simple scenarios requires some deeper understanding. A deeper data parallelism understanding actually entails learning how to work with a core set of TPL classes.

That same reasoning goes for learning task parallelism. A developer can leverage task parallelism with a few TPL classes. Again, though, diverging from well-defined scenarios requires understanding ...

Get Real World .NET 4, C#, and Silverlight®: Indispensible Experiences from 15 MVPs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.