2010-04-07 Rodrigo Kumpera <rkumpera@novell.com>
[mono-project.git] / mono / tests / delegate-exit.cs
blobbf4adfd981fadf2cb83240451a8d9d3bf7a7af16
1 using System;
2 using System.Threading;
3 using System.Runtime.InteropServices;
5 class foo {
6 delegate void foo_delegate ();
8 static void function () {
9 Console.WriteLine ("Delegate method");
12 static void async_callback (IAsyncResult ar)
14 Console.WriteLine ("Async callback " + ar.AsyncState);
17 public static void Main () {
18 foo_delegate d = new foo_delegate (function);
19 AsyncCallback ac = new AsyncCallback (async_callback);
20 IAsyncResult ar1 = d.BeginInvoke (ac, "foo");
22 Console.WriteLine("Waiting");
23 ar1.AsyncWaitHandle.WaitOne();
24 Console.WriteLine("Sleeping");
25 Thread.Sleep(1000);
26 Console.WriteLine("EndInvoke");
27 d.EndInvoke(ar1);
28 Console.WriteLine("Sleeping");
30 Thread.Sleep(1000);
31 Console.WriteLine("Main returns");