Parallel Extensions
suggest changeParallel Extensions were introduced with the Task Parallel Library to support data parallelism: the same operation runs concurrently on elements of a source collection or array. The library provides Parallel.For and Parallel.ForEach.
//Sequential version
foreach (var item in sourcecollection){
Process(item);
}
// Parallel equivalent
Parallel.ForEach(sourceCollection, item => Process(item));
Parallel.ForEach can use more than one core. It does not make every loop faster: the work per item has to be large enough to pay for the partitioning.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents