Export (0) Print
Expand All

ThreadPool.SetMaxThreads Method

Sets 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)

public static bool SetMaxThreads (
	int workerThreads,
	int completionPortThreads
)
public static boolean SetMaxThreads (
	int workerThreads, 
	int completionPortThreads
)
public static function SetMaxThreads (
	workerThreads : int, 
	completionPortThreads : int
) : boolean
Not applicable.

Parameters

workerThreads

The maximum number of worker threads in the thread pool.

completionPortThreads

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

Return Value

true if the change is successful; otherwise, false.

You cannot set the number of worker threads or the number of I/O completion threads to a number smaller than the number of processors in the computer.

If the common language runtime is hosted, for example by Internet Information Services (IIS) or SQL Server, the host can limit or prevent changes to the thread pool size.

Use caution when changing the maximum number of threads in the thread pool. While your code might benefit, the changes might have an adverse effect on code libraries you use.

Setting the thread pool size too large can cause performance problems. If too many threads are executing at the same time, the task switching overhead becomes a significant factor.

Windows Mobile 2003 for Pocket PC, Windows Mobile 2003 for Smartphone, Windows CE Platform Note: The maximum value that can be set is 256.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

.NET Compact Framework

Supported in: 2.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2014 Microsoft