In this chapter, we covered all aspects of imperative data parallelism. In Chapter 10, Parallel LINQ – PLINQ, we will cover declarative data parallelism with PLINQ discussion. Data parallelism using TPL in .NET really comes down to performing parallel loops using the
Parallel.ForEach methods. These parallel loops allow us to iterate through a set or collection of data and perform the same function on each member of the set concurrently.
We learned how to perform a parallel loop on a set of data using
Parallel.For and a collection of data using
Parallel.ForEach. We then saw how to stop or break from a loop when a particular condition was reached; for this we used the
ParallelLoopState object that .NET can generate.