Advertisement
Guest User

Untitled

a guest
Feb 25th, 2014
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1.     internal class Program
  2.     {
  3.         private static void Main()
  4.         {
  5.             new Example().Do();
  6.  
  7.             Console.Read();
  8.         }
  9.     }
  10.  
  11.     internal class Example
  12.     {
  13.         public delegate void MyDelegate();
  14.  
  15.         public void Do()
  16.         {
  17.             Console.WriteLine("Do begins");
  18.             MyDelegate dl = Foo;
  19.             Console.WriteLine("Do after dl = Foo");
  20.             dl.BeginInvoke(Completed, dl);
  21.             Console.WriteLine("Do after dl.BeginInvoke");
  22.             Console.WriteLine("Do ends");
  23.         }
  24.  
  25.         public void Completed(IAsyncResult ar)
  26.         {
  27.             Console.WriteLine("Completed begins");
  28.             MyDelegate dl = (MyDelegate)ar.AsyncState;
  29.             Console.WriteLine("Completed after dl = AsyncState");
  30.             dl.EndInvoke(ar);
  31.             Console.WriteLine("Completed after dl.EndInvoke");
  32.         }
  33.  
  34.         private void Foo()
  35.         {
  36.             Console.WriteLine("Doing Foo stuff");
  37.         }
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement