Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-async-54.cs
1 using System;
2 using System.Threading;
3 using System.Threading.Tasks;
4
5 class Test
6 {
7         public static int Main ()
8         {
9                 int res;
10                 res = TestMethod (new TaskCanceledException ()).Result;
11                 if (res != 0)
12                         return 10 * res;
13
14                 res = TestMethod (new OperationCanceledException ("my message")).Result;
15                 if (res != 0)
16                         return 20 * res;
17
18                 return 0;
19         }
20
21         async static Task<int> TestMethod (Exception ex)
22         {
23                 try {
24                         await Foo (ex);
25                 } catch (OperationCanceledException e) {
26                         if (e == ex)
27                                 return 0;
28
29                         return 1;
30                 }
31
32                 return 2;
33         }
34
35
36         async static Task Foo (Exception e)
37         {
38                 await Task.Delay (1);
39                 throw e;
40         }
41 }