namespace ThreadPoolTestCase
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 10000; i++)
{
int state = i;
AssignWork(state);
Console.WriteLine(i);
}
Console.ReadKey();
}
public static void AssignWork(object s)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(DoWork), (object)s);
Console.WriteLine(s);
//wait.Reset();
}
private static void DoWork(object o)
{//may be smtp works here;
Console.WriteLine("abcdef");
for (int i = 0; i < 100000; i++)
{
Console.WriteLine("abcdef");
Thread.Sleep(1000);
}
//
}
}
}
c# ThreadPool 应用实例
最新推荐文章于 2024-08-07 19:16:11 发布