Fix bug #566087.
[mcs.git] / tests / test-107.cs
bloba5639efa8f067c6283f5df91e24bf4b72043d15c
1 using System;
2 using System.Threading;
3 using System.Runtime.InteropServices;
4 using System.Runtime.Remoting.Messaging;
6 class Test {
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);
22 cb_state++;
23 SimpleDelegate d = (SimpleDelegate)ares.AsyncDelegate;
25 if (cb_state < 5)
26 d.BeginInvoke (cb_state, ac, cb_state);
28 //throw new NotImplementedException ();
31 static int Main () {
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 ();
40 while (cb_state < 5)
41 Thread.Sleep (200);
43 return 0;