TPL - Difference between MaxDegreeOfParallelism and MaximumConcurrencyLevel
What's the difference开发者_如何学Go between ParallelOptions.MaxDegreeOfParallelism
and ParallelOptions.TaskScheduler.MaximumConcurrencyLevel
? When would you use either?
Using reflector, I've gathered that both are used in EffectiveMaxConcurrencyLevel
property:
internal int EffectiveMaxConcurrencyLevel
{
get
{
int maxDegreeOfParallelism = this.MaxDegreeOfParallelism;
int maximumConcurrencyLevel = this.EffectiveTaskScheduler.MaximumConcurrencyLevel;
if ((maximumConcurrencyLevel > 0) && (maximumConcurrencyLevel != 0x7fffffff))
{
maxDegreeOfParallelism = (maxDegreeOfParallelism == -1) ? maximumConcurrencyLevel : Math.Min(maximumConcurrencyLevel, maxDegreeOfParallelism);
}
return maxDegreeOfParallelism;
}
}
精彩评论