Parallel Running Task Window in Visual Studio 2010

Visual Studio 2010 has provided lots of facilities for developers writing applications targeting various .NET versions. The .NET 4.0 Framework has introduced task parallel library using which you can write code which makes use of the available cores on the deployment machine.

Now as a developer, if you are working on multiple asynchronous operations, you can make use of  the Task class. I have already explained the mechanism of coding using task parallel library over here.

Now if you want to view the visual schedule of the parallel tasks and see each object in the thread, Visual 2010 has provided us this capability using Debug > Windows > Parallel Task window.

Let’s consider the following console application:

task parallel library example

Step 1: To view the ‘Parallel Task’ window, put a BREAKPOINT on the ‘taskDepartments’ declaration code as shown below:

parallel window breakpoint

Step 2: Run the application and click on Debug > Windows > Parallel Tasks. You will see the Parallel Task Window as circled below:

parallel task window

Step 3: Now step through the code, and you will find the Task entries in the Parallel Tasks Window as shown below:

parallel task window

The above image of the Parallel Tasks window shows that two Tasks are running. Currently the control is on the ‘taskDepartments’ task object, so the Location provides the operation being handled by the current running task.

parallel task window

Similarly, in the above image, we can see that the task ‘taskEmployees’ is running and handling ‘ReadAllEmployees’ operation.

In both the images, the ‘Thread Assigned’ represents the thread on which the Tasks are running.

Conclusion: With the use of Visual Studio 2010 and Task Parallel Framework in .NET 4.0, it is easy for the developer to work on parallel programming and monitor it.





About The Author

Mahesh Sabnis is a Microsoft MVP having over 18 years of experience in IT education and development. He is a Microsoft Certified Trainer (MCT) since 2005 and has conducted various Corporate Training programs for .NET Technologies (all versions). He also blogs regularly at DotNetCurry.com. Follow him on twitter @maheshdotnet

No comments: