ThreadPoolGroupingOptions

System.Threading
Specifies options for grouping thread pool threads. This enumeration is used by the ThreadPool.GetAvailableThreads and ThreadPool.GetMaxThreads methods to retrieve specific thread counts.

Type

enum

Namespace

System.Threading

Assembly

System.Runtime.dll

Members

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.

Remarks

This enumeration allows fine-grained control over which thread pool thread counts are queried. For example, to get the total number of available worker threads and the total number of available I/O completion port threads, you would call ThreadPool.GetAvailableThreads twice, once with ThreadPoolGroupingOptions.AvailableWorkThreads and once with ThreadPoolGroupingOptions.AvailableCompletionPortThreads.

Example

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}"); } }