Yes, your callback method is executed when the thread stream thread becomes available. In this example, you can see that I am passing PooledProc as a callback pointer. This is called when the main thread is sleeping.
public static void Main() { ThreadPool.QueueUserWorkItem(new WaitCallback(PooledProc)); Console.WriteLine("Main thread"); Thread.Sleep(1000); Console.WriteLine("Done from Main thread"); Console.ReadLine(); }
Obviously, the parameter type QueueUserWorkItem is the delegate type WaitCallback, and if you examine it, you may notice that the WaitCallBack signature is similar:
public delegate void WaitCallback(object state);
The PooledProc method has the same signature, and therefore, we can pass the same for the callback.
source share