Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- internal class Program
- {
- private static void Main()
- {
- new Example().Do();
- Console.Read();
- }
- }
- internal class Example
- {
- public delegate void MyDelegate();
- public void Do()
- {
- Console.WriteLine("Do begins");
- MyDelegate dl = Foo;
- Console.WriteLine("Do after dl = Foo");
- dl.BeginInvoke(Completed, dl);
- Console.WriteLine("Do after dl.BeginInvoke");
- Console.WriteLine("Do ends");
- }
- public void Completed(IAsyncResult ar)
- {
- Console.WriteLine("Completed begins");
- MyDelegate dl = (MyDelegate)ar.AsyncState;
- Console.WriteLine("Completed after dl = AsyncState");
- dl.EndInvoke(ar);
- Console.WriteLine("Completed after dl.EndInvoke");
- }
- private void Foo()
- {
- Console.WriteLine("Doing Foo stuff");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement