QueueUserWorkItem and RegisterWaitForSingleObject: Queue a task, represented by the ThreadProc method, using the QueueUserWorkItem method. : ThreadPool « Thread « C# / CSharp Tutorial
20.28.15.QueueUserWorkItem and RegisterWaitForSingleObject: Queue a task, represented by the ThreadProc method, using the QueueUserWorkItem method.
using System; using System.Threading; public class Example { public static void Main() {
ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadProc));
Thread.Sleep(1000);
Console.WriteLine("Main thread exits.");
} static void ThreadProc(Object stateInfo) {
Console.WriteLine("Hello from the thread pool.");
}
}