Add more test files
[mono.git] / mcs / tests / test-async-04.cs
1 // Compiler options: -langversion:future
2
3 using System;
4 using System.Threading.Tasks;
5 using System.Threading;
6
7 class C
8 {
9         ManualResetEvent mre = new ManualResetEvent (false);
10
11         public async Task<int> TestTaskGeneric ()
12         {
13                 await Task.Factory.StartNew (() => {
14                         mre.WaitOne (3000);
15                         return 5;
16                 });
17
18                 return 1;
19         }
20
21         public static int Main ()
22         {
23                 var c = new C ();
24                 var t2 = c.TestTaskGeneric ();
25                 if (t2.Status != TaskStatus.WaitingForActivation)
26                         return 1;
27
28                 c.mre.Set ();
29                 if (!Task.WaitAll (new[] { t2 }, 3000))
30                         return 2;
31
32                 if (t2.Result != 1)
33                         return 3;
34
35                 if (t2.Status != TaskStatus.RanToCompletion)
36                         return 4;
37
38                 return 0;
39         }
40 }