ParallelOptions.MaxDegreeOfParallelism
和ParallelOptions.TaskScheduler.MaximumConcurrencyLevel
之间有什么区别?你什么时候使用?
答案 0 :(得分:8)
使用反射器,我收集到两者都在EffectiveMaxConcurrencyLevel
属性中使用:
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;
}
}