2 using System
.Threading
;
3 using System
.Runtime
.InteropServices
;
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
);
15 throw new SystemException("Async throws exception");
18 public static void Main () {
19 foo_delegate d
= new foo_delegate (function
);
20 AsyncCallback ac
= new AsyncCallback (async_callback
);
21 IAsyncResult ar1
= d
.BeginInvoke (ac
, "foo");
23 ar1
.AsyncWaitHandle
.WaitOne();
27 Console
.WriteLine("Main returns");