Parallel Extensions: Building Multicore Applications with .NET

Version: 1.1.0

Description

Microsoft's Parallel Computing Platform (PCP) is providing tools enabling developers to leverage the power of Multicore processors in an efficient, maintainable, and scalable manner. Parallel Extensions to the .NET Framework brings several important concepts into this toolset. In this Hands-On Lab, you will learn how to parallelize an existing algorithm by using the static Parallel helper class, create and run Tasks, use the Future<T> class to create and run Tasks that return a value and use Parallel LINQ (PLINQ) to optimize LINQ queries to exectue in a parallel environment.

Overview

Modern computers have seen explosive growth in the number of processors and cores available for systems running on them. System developers can take advantage of this power in a number of ways in their software, particularly when working on complex algorithms or large sets of data.

Microsoft’s Parallel Computing Platform (PCP) is providing tools enabling developers to leverage this power in an efficient, maintainable, and scalable manner. Parallel Extensions brings to the .NET Framework several important concepts into this toolset: imperative and task parallelism via the Task Parallel Library (TPL), and Parallel LINQ (PLINQ), which gives developers a declarative way to deal with data parallelism.

Objectives

In this Hands-On Lab, you will learn how to:

  • Parallelize an existing algorithm by using the static Parallel helper class and have the expression of concurrency handled automatically.
  • Create and run Tasks that enable abilities like cancellation of in-process tasks.
  • Use the Task<T> class to create and run Tasks that return a value.
  • Use Parallel LINQ (PLINQ) to optimize LINQ queries to exectue in a parallel environment.

System Requirements

You must have the following items to complete this lab:

  • Microsoft Visual Studio 2010
  • NET Framework 4

Setup

All the requisites for this lab are verified using the Configuration Wizard. To make sure that everything is correctly configured, follow these steps.

  1. Run the Configuration Wizard for the Training Kit if you have not done it previously. To do this, browse to Source\Setup folder of this lab, and double-click the Dependencies.dep file. Install any pre-requisites that are missing (rescanning if necessary) and complete the wizard.

    Note:
    The Configuration Wizard is used for checking dependencies and setting up the environment. If the Configuration Wizard is not installed on your machine, you must install it running the DependencyChecker.msi file located on the %VS2010TKInstallationFolder%\Assets\DependencyChecker folder (e.g. by default the Training Kit is installed under C:\VS2010TrainingKit).

    For convenience, much of the code you will be managing along this lab is available as Visual Studio code snippets. The Dependencies.dep file launches the Visual Studio installer file that installs the code snippets.

Exercises

This Hands-On Lab is comprised by the following exercises:

Estimated time to complete this lab: 60 minutes.

Note:
Each exercise is accompanied by an End folder containing the resulting solution you should obtain after completing the exercises. You can use this solution as a guide if you need additional help working through the exercises.

Note:
Each exercise contains a Visual Basic and a C# version; Inside the End/Begin solution folder you will find two folders: VB, containing the Visual Basic version of the exercise, and C#, containing the C# version of it.

Next Step:

Exercise 1: Parallelize an Existing Algorithm using the Static Parallel Helper Class