Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-async-66.cs
1 using System;
2 using System.Threading.Tasks;
3
4 class TestFinally
5 {
6         static int counter;
7
8         async static Task Test (bool throwException)
9         {
10                 try {
11                         if (throwException)
12                                 throw new ApplicationException ();
13
14                         ++counter;
15                         System.Console.WriteLine ();
16                 } finally {
17                         counter += 10;
18                         await Task.Delay (2);
19                         counter += 100;
20                 }
21                 counter += 1000;
22         }
23
24         static int Main ()
25         {
26                 Test (false).Wait ();
27                 if (counter != 1111)
28                         return 1;
29
30                 counter = 0;
31                 try {
32                         Test (true).Wait ();
33                         return 2;
34                 } catch (AggregateException) {                  
35                 }
36
37                 if (counter != 110)
38                         return 3;
39
40                 return 0;
41         }
42 }