Introducing .net parallel programming - C#. NET

This is about the parallel programming features of .NET 4, specifically the Task Parallel Library (TPL), Parallel LINQ, and the legion of support classes that make writing parallel programs with C# simpler and easier than ever before.

With the widespread use of multiprocessor and multicore computers, parallel programming has gone mainstream. Or it would have, if the tools and skills required had been easier to use and acquire.

Microsoft has responded to the need for a better way to write parallel programs with the enhancements to the .NET framework

.NET has had support for parallel programming since version 1.0, now referred to as classic threading, but it was hard to use and made you think too much about managing the parallel aspects of your program, which detracts from focusing on what needs to be done.

The new .NET parallel programming features are built on top of the classic threading support. The difference between the TPL and classic threading becomes apparent when you consider the basic programming unit each uses. In the classic model, the programmer uses threads. Threads are the engineof execution, and you are responsible for creating them, assigning work to them, and managing their existence. In the classic approach, you create a little army to execute your program, give all the soldiers their orders, and keep an eye on them to make sure they do as they were told. By contrast, the basic unit of the TPL is the task, which describes something you want done. You create tasks for each activity you want performed, and the TPL takes care of creating threads and dealing with them as they undertake the work in your tasks. The TPL is task-oriented, while the classic threading model is worker-oriented.

Tasks let you focus primarily on what problem you want to solve instead of on the mechanics of how it will get done. If you have tried parallel programming with classic threads and given up, you will find the new features have a refreshing and enabling approach. You can use the new features without having to know anything about the classic features. You’ll also find that the new features are much better thought out and easier to use.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

C#. NET Topics