using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
delegate int wt(int a, int b);
static void Main(string[] args)
{
wt w = new wt(classAdd.Add);
IAsyncResult ar = w.BeginInvoke(5,4,new AsyncCallback(回调函数),"ok");
Console.WriteLine("继续执行后面的");
Console.ReadKey();
}
static void 回调函数(IAsyncResult ar)
{
wt w = (wt)((System.Runtime.Remoting.Messaging.AsyncResult)ar).AsyncDelegate;
Console.WriteLine(w.EndInvoke(ar));
Console.WriteLine(ar.AsyncState);
}
}
class classAdd
{
public static int Add(int a,int b)
{
Console.WriteLine("计算{0},{1}",a,b);
System.Threading.Thread.Sleep(2000);
Console.WriteLine("计算结束");
return a + b;
}
}
}