[ 来源:http://www.it55.com | 作者: | 时间:2007-12-24 | 收藏 | 推荐 ] 【大 中 小】
delegate { Console.WriteLine("b"); },
delegate { Console.WriteLine("c"); }
);
Console.WriteLine("Main thread does some work, then sleeps.");
// If you comment out the Sleep, the main thread exits before
// the thread pool task runs. The thread pool uses background
// threads, which do not keep the application running. (This
// is a simple example of a race condition.)
Thread.Sleep(1000);
Console.WriteLine("Main thread exits.");
}
// This thread procedure performs the task.
static void ThreadProc()
{
// No state object was passed to QueueUserWorkItem, so
// stateInfo is null.
Console.WriteLine("Hello from the thread pool.()");
}
// This thread procedure performs the task.
static void ThreadProc(object stateInfo)
{
// No state object was passed to QueueUserWorkItem, so
// stateInfo is null.
Console.WriteLine("Hello from the thread pool.(object stateInfo)");
}
}
}
(编辑:IT资讯之家 www.it55.com)