Chapter 21: Summary

In this chapter, we discussed how to use the TPL Parallel class for both for and foreach type iterations. In addition, via the AsParallel() extension method included in System.Linq, we demonstrated how to execute LINQ queries in parallel. The ease with which this is accomplished should help you recognize that parallel iteration is one of the easiest ways to introduce parallel execution. Although it is still necessary to be aware of race conditions and deadlocks, these issues are far less likely to occur if you do not share data within the iterations of a parallel loop than if you work with tasks directly. All that remains is identifying the CPU-intensive code blocks that can benefit from parallel execution.

{{ snackbarMessage }}