static int Thread1(int a,int b) {
Console.WriteLine("Thread1");
return a + b;
}
static void CallBack(IAsyncResult ar) {
Func<int, int, int> th = ar.AsyncState as Func<int, int, int>;
int result = th.EndInvoke(ar);
Console.WriteLine("结果为:" + result);
}
Func<int, int, int> th = Thread1;
th.BeginInvoke(9, 10, CallBack, th);IAsyncResult ar为回调自动传参
通过AsyncState获取BeginInvoke方法最后一个参数传入的数据