using System;
delegate void FuncToCall(string s);
class MainClass
{
public static void WriteLineCallback(IAsyncResult iar)
{
Console.WriteLine("In WriteLineCallback");
FuncToCall func = (FuncToCall) iar.AsyncState;
func.EndInvoke(iar);
}
public static void CallWriteLineWithCallback(string s)
{
FuncToCall func = new FuncToCall(Console.WriteLine);
func.BeginInvoke(s, new AsyncCallback(WriteLineCallback), func);
}
public static void Main()
{
CallWriteLineWithCallback("Hello There");
System.Threading.Thread.Sleep(1000);
}
}
Hello There
In WriteLineCallback