using System;
using System.Threading;
public delegate string WashCar(Car carToDetail);
public class Car{}
class MainClass
{
public static string DetailCar(Car c)
{
Console.WriteLine("Detailing car on thread {0}", Thread.CurrentThread.GetHashCode());
Thread.Sleep(10000);
return "Your car is ready!";
}
static void Main(string[] args)
{
Console.WriteLine("Main() is on thread {0}", Thread.CurrentThread.GetHashCode());
WashCar d = new WashCar(DetailCar);
Car myCar = new Car();
IAsyncResult itfAR = d.BeginInvoke(myCar, null, null);
Console.WriteLine("Done invoking delegate");
string msg = d.EndInvoke(itfAR);
Console.WriteLine(msg);
}
}