Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / bug-80392.2.cs
1 using System;
2 using System.Threading;
3 using System.Runtime.InteropServices;
4
5 class Test {
6         delegate int SimpleDelegate (int a);
7
8         static int Method (int a) {
9                 return a;
10         }
11
12         static void Callback (IAsyncResult ar)
13         {
14         }
15         
16         static int Main () {
17                 SimpleDelegate d1 = new SimpleDelegate (Method);
18                 SimpleDelegate d2 = new SimpleDelegate (Method);
19
20                 AsyncCallback ac = new AsyncCallback (Callback);
21                 
22                 IAsyncResult ar1 = d1.BeginInvoke (1, ac, null);
23                 IAsyncResult ar2 = d2.BeginInvoke (2, ac, null);
24
25                 try {
26                         d1.EndInvoke (ar2);
27                         return 1;
28                 } catch (InvalidOperationException) {
29                         // expected
30                 }
31
32                 try {
33                         d2.EndInvoke (ar1);
34                         return 2;
35                 } catch (InvalidOperationException) {
36                         // expected
37                 }
38
39                 if (1 != d1.EndInvoke (ar1)) return 3;
40                 if (2 != d2.EndInvoke (ar2)) return 4;
41
42                 return 0;
43         }
44 }