SHARE
TWEET

Untitled

a guest Feb 25th, 2014 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top