2 using System.Threading;
3 using System.Runtime.InteropServices;
4 using System.Runtime.Remoting.Messaging;
7 delegate int SimpleDelegate (int a);
9 static int cb_state = 0;
11 static int F (int a) {
12 Console.WriteLine ("Test.F from delegate: " + a);
13 throw new NotImplementedException ();
16 static void async_callback (IAsyncResult ar)
18 AsyncResult ares = (AsyncResult)ar;
19 AsyncCallback ac = new AsyncCallback (async_callback);
21 Console.WriteLine ("Async Callback " + ar.AsyncState);
23 SimpleDelegate d = (SimpleDelegate)ares.AsyncDelegate;
26 d.BeginInvoke (cb_state, ac, cb_state);
28 //throw new NotImplementedException ();
32 SimpleDelegate d = new SimpleDelegate (F);
33 AsyncCallback ac = new AsyncCallback (async_callback);
35 IAsyncResult ar1 = d.BeginInvoke (cb_state, ac, cb_state);
37 ar1.AsyncWaitHandle.WaitOne ();