static void Main(string[] args)
{
MyDelegate d =new MyDelegate(MyClass.Method1);
string strEnd = d();
Console.WriteLine(strEnd);
d = new MyDelegate(MyClass.Method2);
IAsyncResult myResult;
myResult = (IAsyncResult)d.BeginInvoke(null,null);
while (myResult.IsCompleted)
{
Console.WriteLine("Thread...");
}
Console.WriteLine("Mehod2 finish");
strEnd = d.EndInvoke(myResult);
Console.WriteLine(strEnd);
Console.ReadLine();
}
}
public class MyClass
{
public static string Method1()
{
return "Hello1";
}
public static string Method2()
{
Thread.Sleep(100);
return "Hello2";
}
}