共用方式為


ProcessModelSection.MaxWorkerThreads 屬性

定義

取得或設定一個值,表示 CLR 執行緒池中每個 CPU 工作執行緒的最大數量。

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

屬性值

執行緒數量最大。 預設值為 20。

屬性

範例

以下程式碼範例說明如何存取該 MaxWorkerThreads 物業。


// 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

備註

MaxWorkerThreads 值必須等於或大於 MinFreeThreads 設定區段中的 httpRuntime 設定值。

你可以透過設定工作執行緒和 I/O 執行緒數量,分別使用 MaxWorkerThreads 屬性和 屬性 MaxIOThreads 來控制 CPU 利用率。

這兩種執行緒的差別在於後者綁定在 I/O 物件,如串流或管線,而前者則是傳統的無限制執行緒。 對於網際網路資訊服務(IIS)6.0 版本及以上版本,ASP.NET 會處理工作執行緒上的請求。 這是因為 ASP.NET 整合在 IIS 中。

這些執行緒來自屬於應用程式的全行程 CLR 執行緒池。

備註

通常允許執行緒的預設值足以維持 CPU 使用率較高。 如果你的應用程式因為某些原因變慢,或許在等待外部資源,你可以嘗試將執行緒數量增加到低於 100 的數值。

適用於

另請參閱