In case I have a collection of objects that each object's process takes lots of time,
what is the difference between EnumerablePartitionerOptions.NoBuffering
and not using Partitioner
at all?
EnumerablePartitionerOptions.NoBuffering:
Create a partitioner that takes items from the source enumerable one at a time and does not use intermediate storage that can be accessed more efficiently by multiple threads. This option provides support for low latency (items will be processed as soon as they are available from the source) and provides partial support for dependencies between items (a thread cannot deadlock waiting for an item that the thread itself is responsible for processing).
Thank you.
Update: who is faster? and why?
IEnumerable<int> Numbers1 = Enumerable.Range(1, 100);
Parallel.ForEach(Numbers1, (number1) => VeryExpensiveMethod(number1));
//
//
Partitioner<int> Numbers2 = Partitioner.Create(Enumerable.Range(1, 100), EnumerablePartitionerOptions.NoBuffering);
Parallel.ForEach(Numbers2, (number1) => VeryExpensiveMethod(number1));