[build] Fix warning (#4177)
[mono-project.git] / mcs / tests / test-async-04.cs
blob8417e7c70d265100b005cc4066ca8c0b50d99726
1 using System;
2 using System.Threading.Tasks;
3 using System.Threading;
5 class C
7 ManualResetEvent mre = new ManualResetEvent (false);
8 ManualResetEvent mre_task = new ManualResetEvent (false);
10 public async Task<int> TestTaskGeneric ()
12 await Task.Factory.StartNew (() => {
13 mre_task.Set ();
14 mre.WaitOne (3000);
15 return 5;
16 }).ConfigureAwait (false);;
18 return 1;
21 public static int Main ()
23 var c = new C ();
25 var t2 = c.TestTaskGeneric ();
26 if (t2.Status != TaskStatus.WaitingForActivation)
27 return 1;
29 c.mre_task.WaitOne (3000);
30 c.mre.Set ();
32 if (!Task.WaitAll (new[] { t2 }, 3000))
33 return 2;
35 if (t2.Result != 1)
36 return 3;
38 if (t2.Status != TaskStatus.RanToCompletion)
39 return 4;
41 return 0;