As we will be familiar with QueueUserWorkItem method of thread pool and which will add your method to the thread pool and will start a background worker thread for execution...
Here I am explaining some of the other useful methods in Thread pool which can be useful in some of the programming scenarios...
Here I am explaining some of the other useful methods in Thread pool which can be useful in some of the programming scenarios...
1. Maximum Number of Thread Pool Threads: You can control the maximum number of threads that can active in a threadpool by using the GetMaxThreads and SetMaxThreads methods. Once it reached the maximum limit, the upcoming equests will be queued into threadpool and will executed once the pool is available.
2. Thread Pool Minimums : The thread pool provides new worker threads or I/O completion threads on demand until it reaches a specified minimum for each category. You can use the GetMinThreads method to obtain these minimum values.
3. RegisterWaitForSingleObject : Registers a deligate for a waithandle . The deligate will be executed in a worker thread on signaling the waithandle. When you are finished using the RegisteredWaitHandle that is returned by this method, call its RegisteredWaitHandle.Unregister method to release references to the wait handle. We recommend that you always call the RegisteredWaitHandle.Unregister method, even if you specifytrue for executeOnlyOnce. Garbage collection works more efficiently if you call the RegisteredWaitHandle.Unregister method instead of depending on the registered wait handle's finalizer.
The RegisterWaitForSingleObject method queues the specified delegate to the thread pool. A worker thread will execute the delegate when one of the following occurs:
=> The specified object is in the signaled state.
=> The time-out interval elapses.
The RegisterWaitForSingleObject method checks the current state of the specified object's WaitHandle. If the object's state is unsignaled, the method registers a wait operation. The wait operation is performed by a thread from the thread pool. The delegate is executed by a worker thread when the object's state becomes signaled or the time-out interval elapses. If the timeOutInterval parameter is not 0 (zero) and theexecuteOnlyOnce parameter is false, the timer is reset every time the event is signaled or the time-out interval elapses.
3. RegisterWaitForSingleObject : Registers a deligate for a waithandle . The deligate will be executed in a worker thread on signaling the waithandle. When you are finished using the RegisteredWaitHandle that is returned by this method, call its RegisteredWaitHandle.Unregister method to release references to the wait handle. We recommend that you always call the RegisteredWaitHandle.Unregister method, even if you specifytrue for executeOnlyOnce. Garbage collection works more efficiently if you call the RegisteredWaitHandle.Unregister method instead of depending on the registered wait handle's finalizer.
The RegisterWaitForSingleObject method queues the specified delegate to the thread pool. A worker thread will execute the delegate when one of the following occurs:
=> The specified object is in the signaled state.
=> The time-out interval elapses.
The RegisterWaitForSingleObject method checks the current state of the specified object's WaitHandle. If the object's state is unsignaled, the method registers a wait operation. The wait operation is performed by a thread from the thread pool. The delegate is executed by a worker thread when the object's state becomes signaled or the time-out interval elapses. If the timeOutInterval parameter is not 0 (zero) and theexecuteOnlyOnce parameter is false, the timer is reset every time the event is signaled or the time-out interval elapses.