Parallel Extensions

suggest change

Parallel 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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents