Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-async-12.cs
1 using System;
2 using System.Threading.Tasks;
3 using System.Threading;
4
5 class C
6 {
7         static async Task<int> TestNested_1 ()
8         {
9                 return Call (
10                         await Task.Factory.StartNew (() => { Thread.Sleep (10); return 5; }).ConfigureAwait (false),
11                         await Task.Factory.StartNew (() => -3).ConfigureAwait (false),
12                         await Task.Factory.StartNew (() => 6).ConfigureAwait (false));
13         }
14
15         static int Call (int arg1, int arg2, int arg3)
16         {
17                 if (arg1 != 5)
18                         return 1;
19
20                 if (arg2 != -3)
21                         return 2;
22
23                 if (arg3 != 6)
24                         return 3;
25
26                 return 0;
27         }
28
29         public static int Main ()
30         {
31                 var t1 = TestNested_1 ();
32                 if (!Task.WaitAll (new[] { t1 }, 1000))
33                         return 1;
34
35                 if (t1.Result != 0)
36                         return 2;
37
38                 Console.WriteLine ("ok");
39                 return 0;
40         }
41 }