"disable_omit_fp" can now be included in MONO_DEBUG
[mono-project.git] / mcs / tests / test-105.cs
blobb88d09578b3aa4e8205ce8ef45c4d9e1b5cff488
1 using System;
2 using System.Threading;
3 using System.Runtime.InteropServices;
5 class Test {
6 delegate int SimpleDelegate (int a);
8 static int F (int a) {
9 Console.WriteLine ("Test.F from delegate: " + a);
10 Thread.Sleep (200);
11 return a;
14 static void async_callback (IAsyncResult ar)
16 Console.WriteLine ("Async Callback " + ar.AsyncState);
19 public static int Main () {
20 SimpleDelegate d = new SimpleDelegate (F);
21 AsyncCallback ac = new AsyncCallback (async_callback);
22 string state1 = "STATE1";
23 string state2 = "STATE2";
24 string state3 = "STATE3";
25 string state4 = "STATE4";
26 int fin = 0;
28 IAsyncResult ar1 = d.BeginInvoke (1, ac, state1);
29 IAsyncResult ar2 = d.BeginInvoke (2, ac, state2);
30 IAsyncResult ar3 = d.BeginInvoke (3, ac, state3);
31 IAsyncResult ar4 = d.BeginInvoke (4, ac, state4);
33 int res = d.EndInvoke (ar1);
35 Console.WriteLine ("Result = " + res);
37 try {
38 d.EndInvoke (ar1);
39 } catch (InvalidOperationException) {
40 Console.WriteLine ("cant execute EndInvoke twice ... OK");
43 ar1.AsyncWaitHandle.WaitOne ();
44 if (ar1.IsCompleted) fin++;
45 Console.WriteLine ("completed1: " + ar1.IsCompleted);
46 ar2.AsyncWaitHandle.WaitOne ();
47 if (ar2.IsCompleted) fin++;
48 Console.WriteLine ("completed2: " + ar2.IsCompleted);
49 ar3.AsyncWaitHandle.WaitOne ();
50 if (ar3.IsCompleted) fin++;
51 Console.WriteLine ("completed3: " + ar3.IsCompleted);
52 ar4.AsyncWaitHandle.WaitOne ();
53 if (ar4.IsCompleted) fin++;
54 Console.WriteLine ("completed4: " + ar4.IsCompleted);
56 if (fin != 4)
57 return 1;
59 return 0;