110,537
社区成员
发帖
与我相关
我的任务
分享
public int addhandler(int a, int b)
{
Console.WriteLine("A");
System.Threading.Thread.Sleep(3000);// 注释代码后无延迟
return a + b;
}
Random r = new Random();
for (int i = 0; i < 50; i++)
{
clstest c = new clstest();
int num1 = r.Next(1, 101);
int num2 = r.Next(1, 101);
add a1 = new add(c.addhandler);
a1.BeginInvoke(num1, num2, new AsyncCallback(c.addCallback), a1);
Console.WriteLine("已启动数量" + i);
}
System.Threading.ThreadPool.QueueUserWorkItem(obj =>
{
Console.WriteLine(1);
System.Threading.Thread.Sleep(3000);
});
Console.WriteLine(2);