WHAT'S IN THIS CHAPTER?
Understanding task parallel problems
Understanding the new task-based programming model and the specific implementation of tasks offered by TPL
Launching, controlling, managing, and synchronizing parallel tasks
Transforming existing sequential code into parallelized code
Returning values from asynchronous tasks
Combining synchronous code with asynchronous code
Mixing parallel and sequential code with continuations
Programming complex parallel algorithms with critical sections using tasks
As explained in Chapter 2, "Imperative Data Parallelism," data parallelism isn't the only form of parallelism. Before .NET Framework 4, it was necessary to create and manage multiple threads or use the pool of threads in order to take advantage of multicore technology or multiple processors. Now, you can work with the new
Task instances to solve imperative task parallelism problems and complex algorithms with simpler code. In this chapter, you will learn about this new .NET Framework 4 model.
This chapter is about the new classes, structures, and enumerations that allow you to deal with imperative task parallelism scenarios. It explains how to create parallel code using tasks instead of threads and describes the new concepts related to each scenario. By the end of the chapter, you will understand how to implement existing algorithms in parallel using basic and complex features offered by the new task-based programming model.