[runtime] Avoid holding the init lock while calling the cctor in mono_runtime_class_i...
[mono-project.git] / mcs / tests / test-async-54.cs
blobab10233198e97aac5341551e104585b19a37c897
1 using System;
2 using System.Threading;
3 using System.Threading.Tasks;
5 class Test
7 public static int Main ()
9 int res;
10 res = TestMethod (new TaskCanceledException ()).Result;
11 if (res != 0)
12 return 10 * res;
14 res = TestMethod (new OperationCanceledException ("my message")).Result;
15 if (res != 0)
16 return 20 * res;
18 return 0;
21 async static Task<int> TestMethod (Exception ex)
23 try {
24 await Foo (ex);
25 } catch (OperationCanceledException e) {
26 if (e == ex)
27 return 0;
29 return 1;
32 return 2;
36 async static Task Foo (Exception e)
38 await Task.Delay (1);
39 throw e;