Warnings cleanup
[mcs.git] / tests / test-106.cs
blob4b6c0530ed37d06574283d216fdb9eebb5d5b511
1 using System;
2 using System.Threading;
3 using System.Runtime.InteropServices;
5 class Test {
6 delegate int SimpleDelegate (int a);
8 static int cb_state = 0;
10 static int F (int a) {
11 Console.WriteLine ("Test.F from delegate: " + a);
12 throw new NotImplementedException ();
15 static void async_callback (IAsyncResult ar)
17 Console.WriteLine ("Async Callback " + ar.AsyncState);
18 cb_state = 1;
19 throw new NotImplementedException ();
22 static int Main () {
23 SimpleDelegate d = new SimpleDelegate (F);
24 AsyncCallback ac = new AsyncCallback (async_callback);
25 string state1 = "STATE1";
26 int res = 0;
28 IAsyncResult ar1 = d.BeginInvoke (1, ac, state1);
30 ar1.AsyncWaitHandle.WaitOne ();
32 try {
33 res = d.EndInvoke (ar1);
35 while (cb_state == 0)
36 Thread.Sleep (0);
38 } catch (NotImplementedException) {
39 res = 1;
40 Console.WriteLine ("received exception ... OK");
43 if (cb_state != 1)
44 return 1;
46 if (res != 1)
47 return 2;
49 return 0;