我读过here:



没错,我检查了一下(我有8核计算机,所以8 * 100 = 800):

但是后来我看到了thisthis:



问题

我看不到数字如何适合这里:

第一段说明每个内核最多有100个线程(图像证明,我有8个内核)。

但是第二段指出每个内核的默认最大工作线程为20。因此,如果我有8个内核,则必须有8 * 20 = 160个最大线程。不是800。

有人可以照亮吗?

更新:

我刚刚找到了一种通过C#代码获取关键元素值的方法:

所以现在数字适合了,但仍然-MSDN say the default is 20 , not 100

然后他们确实提到100:

这里发生了什么

最佳答案

我查看了源代码,发现MaxWorkerThreads的默认值设置为100

private static readonly ConfigurationProperty _propMaxWorkerThreads = new ConfigurationProperty("maxWorkerThreads", typeof (int), (object) 100, (TypeConverter) null, (ConfigurationValidatorBase) new IntegerValidator(1, 2147483646), ConfigurationPropertyOptions.None);

此字段添加到静态构造函数的属性集合中
ProcessModelSection._properties.Add(ProcessModelSection._propMaxWorkerThreads);

在属性定义中,它们确实将默认值设置为20
[IntegerValidator(MaxValue = 2147483646, MinValue = 1)]
[ConfigurationProperty("maxWorkerThreads", DefaultValue = 20)]
public int MaxWorkerThreads

但这显然不起作用。也许这是某种传统的实现。顺便说一下,仅当autoConfig设置为false时,它的行为才如此。设置为true时,我的应用程序中有32K工作线程。此行为可能取决于IIS版本。

10-06 09:19