ProcessModelSection.MaxWorkerThreads Property
本文内容
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a value indicating the maximum amount of worker threads per CPU in the CLR thread pool.
public:
property int MaxWorkerThreads { int get(); void set(int value); };
[System.Configuration.ConfigurationProperty("maxWorkerThreads", DefaultValue=20)]
[System.Configuration.IntegerValidator(MaxValue=2147483646, MinValue=1)]
public int MaxWorkerThreads { get; set; }
[<System.Configuration.ConfigurationProperty("maxWorkerThreads", DefaultValue=20)>]
[<System.Configuration.IntegerValidator(MaxValue=2147483646, MinValue=1)>]
member this.MaxWorkerThreads : int with get, set
Public Property MaxWorkerThreads As Integer
The maximum number of threads. The default is 20.
- Attributes
The following code example shows how to access the MaxWorkerThreads property.
// Get the current MaxWorkerThreads property value.
int maxWorkerThreads =
processModelSection.MaxWorkerThreads;
// Set the MaxWorkerThreads property to 128.
processModelSection.MaxWorkerThreads = 128;
' Get the current MaxWorkerThreads property value.
Dim maxWorkerThreads As Integer = _
processModelSection.MaxWorkerThreads
' Set the MaxWorkerThreads property to 128.
processModelSection.MaxWorkerThreads = 128
The value of MaxWorkerThreads must be equal to or greater than the MinFreeThreads setting in the httpRuntime
configuration section.
You can have some control over the CPU utilization by setting the number of worker threads and I/O threads, using the MaxWorkerThreads property and, the MaxIOThreads property, respectively.
The difference between the two types of threads is that the latter are bound to I/O objects, such as a stream or a pipe, and the former are traditional unrestricted threads. For Internet Information Services (IIS) version 6.0 and higher, ASP.NET processes requests on worker threads. This is because ASP.NET is integrated within IIS.
These threads are obtained from the process-wide CLR thread pool belonging to an application.
备注
Usually the default values for the allowed threads are sufficient to keep the CPU utilization high. If for some reason your application is slow, perhaps waiting for external resources, you could try to increase the number of threads to a value less than 100.
Applies to
产品 | 版本 |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |