Пример #1
0
        static void Main(string[] args) {
            Console.WriteLine("-> Main thread started . ThreadID = {0}", Thread.CurrentThread.ManagedThreadId);

            Printer p = new Printer();
            WaitCallback workItem = new WaitCallback(PrintTheNumbers);
            for (int i = 0; i < 10; i++) {
                ThreadPool.QueueUserWorkItem(workItem, p);
            }
            Console.WriteLine("All tasks queued");
            Console.ReadLine();
        }
Пример #2
0
        static void PrintTheNumbers(object state)
        {
            Printer task = (Printer)state;

            task.PrintNumbers();
        }