Online resource kit >

HomeAt a GlanceDeveloperIT Pro

Parallel Programming for Managed Developers with the Next Version of Microsoft Visual Studio

< Go Back

This talk covers new APIs and tools available in the Microsoft .NET Framework 4.0 and Microsoft Visual Studio 2010 to help developers write parallel applications. This is significant because concurrency is still important for responsiveness even for applications that will only be running on computers with a single core. Applications should be written not only to avoid blocking the UI thread, but also to perform I/O in a manner that overlaps as much as possible to decrease overall latencies.

On multi-core machines, however, the multitude of cores can be used to partition work into pieces, which are then executed on all available processors. This improves the user’s experience by making their applications run faster, and it enables new experiences in the future as the number of cores trends with Moore’s Law.

The session walks through new changes that are being made to the common language runtime (CLR), including how the Microsoft .NET thread pool is being optimized through new “work-stealing” algorithms. The session shows new Task APIs in the System.Threading.Tasks namespace that provide rich support for creating tasks, waiting on tasks, canceling tasks, continuing from tasks, and so forth, but without the overheads of using threads. The session also demonstrates how these new Task APIs have new debugging support, with new tool windows that provide details about all of scheduled and running tasks in the system, and a new window that takes all of the thread stacks and displays them in a concise, interactive graphical format using Windows Presentation Foundation (WPF).

The session then highlights the new Parallel class that is being introduced in .NET 4.0. This static class provides utility methods meant to be substituted for language constructs like for and foreach loops, executing such loops in parallel instead of sequentially. The session then moves on to new LINQ support for parallelism in .NET 4.0, Parallel LINQ (PLINQ). Simply add “.AsParallel()” to your LINQ-to-Objects query and the system parallelizes the processing of the query across all of the cores in your machine.

To wrap up, the session provides a bucket list of several new types being added to the existing System.Threading namespace and to the new System.Collections.Concurrent namespace, including a new ConcurrentDictionary type that supports multiple readers and writers concurrently, types meant to simplify doing producer/consumer applications, and a type that makes it simpler to do thread-safe lazy initialization.

The session includes the following demonstrations:

  • Introduction: Teaser client application switching from single core to parallel
  • Task–rich API: Moving processing from single thread to multi-thread and then to the parallel extensions. Threads -> Tasks
  • Debugger: Task/thread tracking through debugger
  • Structured parallelism: Parallel class
  • Declarative data parallelism: PLINQ .AsParallel
  • Coordination data structures: New bits in the literature
View