When the.NET framework receives a call method request, it generates a new thread object, allocates memory for it, and then begins task execution. When the task is completed, the garbage collector destroys the thread object to release memory space.
For each request that comes in a multithread application, memory is allocated each time a new thread object is generated, which results in memory load that may slow down your application. Hence, the need for pooling.
In C#, thread pooling is defined as a collection of threads and designed to perform background tasks. When a thread completes a task, it is added to the queue, which contains all the threads that are currently waiting. This is done to allow reuse threads.
To implement thread pooling, use threading namespace.
using System.Threading;
The ThreadPool.QueueUserWorkItem that is taken by Waitcallback method, (overloaded method) represents a callback function that will be invoked by a thread pool.
ThreadPool.QueueUserWorkItem(new WaitCallback(MyMethod));