Export (0) Print
Expand All

ThreadPool.GetMaxThreads Method

Retrieves the number of requests to the thread pool that can be active concurrently. All requests above that number remain queued until thread pool threads become available.

Namespace:  System.Threading
Assembly:  mscorlib (in mscorlib.dll)

static member GetMaxThreads : 
        workerThreads:int byref * 
        completionPortThreads:int byref -> unit

Parameters

workerThreads
Type: System.Int32

The maximum number of worker threads in the thread pool.

completionPortThreads
Type: System.Int32

The maximum number of asynchronous I/O threads in the thread pool.

When GetMaxThreads returns, the variable specified by workerThreads contains the maximum number of worker threads allowed in the thread pool, and the variable specified by completionPortThreads contains the maximum number of asynchronous I/O threads allowed in the thread pool.

You can use the GetAvailableThreads method to determine the actual number of threads in the thread pool at any given time.

You can use the SetMaxThreads to set the maximum number of worker threads and asynchronous I/O threads in the thread pool.

You can queue as many thread pool requests as system memory allows. If there are more requests than thread pool threads, the additional requests remain queued until thread pool threads become available.

The following code example shows how to retrieve a count of the maximum and available number of threads in the thread pool. A work item is queued that uses FileStream to asynchronously write to two files. The callback methods are timed to overlap. A worker thread handles the work item and, depending on the speed and number of processors on the computer, one or two completion port threads handle the write operations.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft