Seeing a good article in CodeProject This section describes how to reset the .NET's CLR thread pool size.
First, it is clear that the GUID of the COM object that sets the thread pool default size is:
// Declare ThreadManager as a COM coclass: [// CLSID_CorRuntimeHost from MSCOREE.DLL Guid ( "CB2F6723-AB3A-11D2-9C40-00C04FA30A3E"), ComImport] class ThreadManager // Can not have a base class or // interface list here. {// Cannot Have Any Members Here // Note That The C # Compiler Will Add A Default Constructor // for You (No Parameters).
Second declaration of the components of the components are:
[// IID_IcorThreadPool Guid ( "84680D3A-B2C1-46e8-ACC2-DBC0A359159A"), InterfaceType (ComInterfaceType.InterfaceIsIUnknown)] public interface ICorThreadpool // Can not list any base interfaces here {// Note that IUnknown Interface members are NOT listed here:
void RegisterWaitForSingleObject (); // Not Implemeted void UnregisterWait ();. // Not Implemeted void QueueUserWorkItem ();. // Not Implemeted void CreateTimer ();. // Not Implemeted void ChangeTimer ();. // Not Implemeted. void DeleteTimer ();. // Not Implemeted void BindIoCompletionCallback ();. // Not Implemeted void CallOrQueueUserWorkItem (); // Not Implemeted void SetMaxThreads (uint MaxWorkerThreads, uint MaxIOCompletionThreads);. void GetMaxThreads (out uint MaxWorkerThreads, out uint MaxIOCompletionThreads ); Void getavailablethreads (Out Uint AvailableWorkerthreads, Out Uint AvailableiocompletionthReads);
OK, then you can set this:
ThreadManager ThreadManager = new threadmanager ();
// queryinterface for the icorthreadpool interface: mscoretypelib.icorthreadpool ct = (mscoretypelib.icorthreadpool) threadManager;
INT MAXWORKERTHREADS = 35; int maxiothreads = 35; ct.setmaxthreads (MaxiThreads, Maxiothreads);