您的位置:首页 > 产品设计 > UI/UE

使用线程池的方法(非TPL)-ThreadPool.QueueUserWorkItem

2011-03-18 23:29 736 查看
.net4.0的TPL(Task Parallel Library)可以访问线程池。

在此之前,访问线程池的方法主要有2种。

ThreadPool.QueueUserWorkItem和异步委托。

static void Main(string[] args)
{
ThreadPool.QueueUserWorkItem(Go);
ThreadPool.QueueUserWorkItem(Go, 123);
Console.ReadLine();
}

static void Go(object data) // data will be null with the first call.
{
Console.WriteLine("Hello from the thread pool! " + data);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: