class Program
{
static int result;
public delegate int test(int a, int b);
static void Main(string[] args)
{
test ts = new test(sum);
ts.BeginInvoke(1, 2, new AsyncCallback(EvaluateCallback), ts);
Console.Write(result);
Console.ReadKey();
}
public static int sum(int a,int b)
{
Thread.Sleep(5000);
return a + b;
}
static void EvaluateCallback(IAsyncResult ar)
{
test ce = ar.AsyncState as test;
if (ce != null)
{
result = ce.EndInvoke(ar);
Console.Write("\r\n" + result);
}
}
}