CSharp Parallel Programming

Last Updated: 3/1/2022

Parallel Programming Introduction

  • Many personal computers and workstations have multiple CPU cores that enable multiple threads to be executed simultaneously.
  • To take advantage of the hardware, you can parallelize your code to distribute work across multiple processors.
  • Visual Studio and .NET enhance support for parallel programming by providing a runtime, class library types, and diagnostic tools.
Namespace: System.Threading.Tasks
Assembly: System.Threading.Tasks.Parallel.dll

Data Parallelism

  • Data parallelism refers to scenarios in which the same operation is performed concurrently (in parallel) on elements in a collection or array.
  • In data parallel operations, the source collection is partitioned so that multiple threads can operate on different segments concurrently.
  • Parallel class provides parallel implementations of for and foreach loops