class Program
{
static void Main(string[] args)
{
Func<int, int> num = Number;
IAsyncResult asyncRes = num.BeginInvoke(10, new AsyncCallback(CallbackMethod), null);
Console.Read();
}
static int Number(int a)
{
Thread.Sleep(5000);
return a + a;
}
static void CallbackMethod(IAsyncResult asyncRes)
{
AsyncResult ares = (AsyncResult)asyncRes;
Func<int, int> delg = (Func<int, int>)ares.AsyncDelegate;
int res = delg.EndInvoke(asyncRes);
Console.WriteLine("Result = {0}", res);
}
}