Студопедия — Exercises. In this Hands-On Lab, you will learn how to
Студопедия Главная Случайная страница Обратная связь

Разделы: Автомобили Астрономия Биология География Дом и сад Другие языки Другое Информатика История Культура Литература Логика Математика Медицина Металлургия Механика Образование Охрана труда Педагогика Политика Право Психология Религия Риторика Социология Спорт Строительство Технология Туризм Физика Философия Финансы Химия Черчение Экология Экономика Электроника

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






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:

· Parallelize an Existing Algorithm by using the Static Parallel Class.

· Create and Run Parallelized Tasks.

· Use the Task<T> Class to Create and Run a Task that Returns a Value.

· Parallelize LINQ Queries using PLINQ.

 

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

 


 

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

In this exercise, you will learn how to parallelize and existing algorithm by using the static Parallel helper class. This allows you to do things like replacing for() with Parallel.For().

Note: To verify that each step is correctly performed, it is recommended to build the solution at the end of each task.

 

Task 1 – Parallelizing a Long Running Service

In this task, you will write some simple sample code that will simulate a long running service call.

You are going to use the PayrollServices.GetPayrollDeduction() method which is provided with the begin solution of this exercise. This is the type of long running code that you would ultimately like to run in parallel.

1. Open Microsoft Visual Studio 2010 from Start | All Programs | Microsoft Visual Studio 2010 | Microsoft Visual Studio 2010.

2. Open the solution file ParallelExtLab.sln located under Source\Ex01-UsingStaticParallelHelper\begin. (Choosing the folder that matches the language of your preference.)

Note: This solution contains a starting point for your work, and includes a helper class EmployeeList which holds the data you’ll be working with.

 

3. In Visual Studio, open the Program.cs (C#) or Module1.vb (Visual Basic) file and navigate to its Main() method. First, you will need to create a list of employees to work on, so add a class variable and initialize it in the Main() method:

 

(Code Snippet – Intro to Parallel Extensions Lab - Ex1 Create employee list CSharp)

C#

class Program

{







Дата добавления: 2015-08-12; просмотров: 370. Нарушение авторских прав; Мы поможем в написании вашей работы!



Вычисление основной дактилоскопической формулы Вычислением основной дактоформулы обычно занимается следователь. Для этого все десять пальцев разбиваются на пять пар...

Расчетные и графические задания Равновесный объем - это объем, определяемый равенством спроса и предложения...

Кардиналистский и ординалистский подходы Кардиналистский (количественный подход) к анализу полезности основан на представлении о возможности измерения различных благ в условных единицах полезности...

Обзор компонентов Multisim Компоненты – это основа любой схемы, это все элементы, из которых она состоит. Multisim оперирует с двумя категориями...

Тактические действия нарядов полиции по предупреждению и пресечению групповых нарушений общественного порядка и массовых беспорядков В целях предупреждения разрастания групповых нарушений общественного порядка (далееГНОП) в массовые беспорядки подразделения (наряды) полиции осуществляют следующие мероприятия...

Механизм действия гормонов а) Цитозольный механизм действия гормонов. По цитозольному механизму действуют гормоны 1 группы...

Алгоритм выполнения манипуляции Приемы наружного акушерского исследования. Приемы Леопольда – Левицкого. Цель...

Подкожное введение сывороток по методу Безредки. С целью предупреждения развития анафилактического шока и других аллергических реак­ций при введении иммунных сывороток используют метод Безредки для определения реакции больного на введение сыворотки...

Принципы и методы управления в таможенных органах Под принципами управления понимаются идеи, правила, основные положения и нормы поведения, которыми руководствуются общие, частные и организационно-технологические принципы...

ПРОФЕССИОНАЛЬНОЕ САМОВОСПИТАНИЕ И САМООБРАЗОВАНИЕ ПЕДАГОГА Воспитывать сегодня подрастающее поколение на со­временном уровне требований общества нельзя без по­стоянного обновления и обогащения своего профессио­нального педагогического потенциала...

Studopedia.info - Студопедия - 2014-2024 год . (0.008 сек.) русская версия | украинская версия