enum
System.Threading
System.Runtime.dll
| Member | Description |
|---|---|
| AvailableCompletionPortThreads | Specifies that the number of available I/O completion port threads should be retrieved. |
| AvailableWorkThreads | Specifies that the number of available worker threads should be retrieved. |
| MaxCompletionPortThreads | Specifies that the maximum number of I/O completion port threads should be retrieved. |
| MaxWorkThreads | Specifies that the maximum number of worker threads should be retrieved. |
ThreadPoolGroupingOptions.AvailableWorkThreads and once with ThreadPoolGroupingOptions.AvailableCompletionPortThreads.
using System;
using System.Threading;
public class Example
{
public static void Main()
{
int workerThreads;
int completionPortThreads;
// Get the maximum number of available worker threads
ThreadPool.GetMaxThreads(out workerThreads, out completionPortThreads);
Console.WriteLine($"Max worker threads: {workerThreads}");
Console.WriteLine($"Max completion port threads: {completionPortThreads}");
// Get the number of currently available worker threads
ThreadPool.GetAvailableThreads(out workerThreads, out completionPortThreads);
Console.WriteLine($"Available worker threads: {workerThreads}");
Console.WriteLine($"Available completion port threads: {completionPortThreads}");
}
}