Chapter 33. Parallel Programming Using Tasks and Threads

WHAT YOU WILL LEARN IN THIS CHAPTER

  • Understanding the new task-based programming model and the Task Parallel Library

  • Launching, controlling, managing, and synchronizing parallel tasks

  • Refactoring loops to run them in parallel using Parallel.For and Parallel.ForEach

  • Transforming existing sequential code into parallelized code

  • Measuring the speed gain and the scalability offered by parallelized code

  • Working with different degrees of parallelism

  • Understanding the advantages of working with concurrent collections

  • Implementing a parallel producer-consumer pattern

  • Parallelizing LINQ queries using PLINQ

In the last few years, multicore technology has become the mainstream in CPU designs, and microprocessor manufacturers continue to improve their processing power. However, the shift to multicore is an inflexion point for software design philosophy.

This chapter is about the new lightweight concurrency model offered by Visual Basic 2010 with .NET Framework 4 and its related hardware technologies. A comprehensive treatment of the challenges offered by the new multicore designs could easily fill 600 pages or more, so this chapter attempts to strike a reasonable balance between detail and succinctness.

LAUNCHING PARALLEL TASKS

It was really difficult to develop applications capable of taking full advantage of multicore microprocessors working with previous .NET Framework versions. It was necessary to launch, control, manage, and synchronize multiple ...

Get Professional Visual Basic® 2010 and .NET 4 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.