using System;
using System.Threading;
public class MainClass
{
private delegate Decimal Compute( int year );
private static Decimal DecimalCompute( int year ) {
Console.WriteLine( "Computing ");
Thread.Sleep( 6000 );
return 6.8M;
}
private static void DealWithResult( IAsyncResult ar ) {
Compute work = (Compute) ar.AsyncState;
Decimal result = work.EndInvoke( ar );
Console.WriteLine( "Result: {0}", result );
}
static void Main() {
Compute work = new Compute( DecimalCompute );
work.BeginInvoke( 2004, new AsyncCallback(DealWithResult),work );
Console.WriteLine( "Waiting for operation to complete." );
Thread.Sleep( 8000 );
}
}