Chapter 3. Parallel Basics

In this chapter, we’ll cover patterns for parallel programming. Parallel programming is used to split up CPU-bound pieces of work and divide them among multiple threads. These parallel processing recipes only consider CPU-bound work. If you have naturally asynchronous operations (such as I/O-bound work) that you wish to execute in parallel, then see Chapter 2, and Recipe 2.4 in particular.

The parallel processing abstractions covered in this chapter are part of the Task Parallel Library (TPL). This is built in to the .NET framework but is not available on all platforms (see Table 3-1):

Table 3-1. Platform support for TPL
PlatformParallel support

.NET 4.5

Yes

.NET 4.0

Yes

Mono iOS/Droid

Yes

Windows Store

Yes

Windows Phone Apps 8.1

Yes

Windows Phone SL 8.0

No

Windows Phone SL 7.1

No

Silverlight 5

3.1. Parallel ...

Get Concurrency in C# Cookbook 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.