Looking at the source, the following code fragment appears: number of workers:
// initialize ranges with passed in loop arguments and expected number of workers int numExpectedWorkers = (parallelOptions.EffectiveMaxConcurrencyLevel == -1) ? Environment.ProcessorCount : parallelOptions.EffectiveMaxConcurrencyLevel;
As far as I can tell, with the default task scheduler and the default ParallelOptions parameter, this is the value of Environment.ProcessorCount , so it is strange that you get a different behavior by pointing MaxDegreeOfParallelism to the processor counter yourself. I suggest you debug it to make sure that there really is a difference (you can print Thread.ManagedThreadId in the long run of the task).
Ohad schneider
source share