linux-packaging-mono/mcs/tests/test-async-04.cs
Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

46 lines
795 B
C#

// Compiler options: -langversion:future
using System;
using System.Threading.Tasks;
using System.Threading;
class C
{
ManualResetEvent mre = new ManualResetEvent (false);
ManualResetEvent mre_task = new ManualResetEvent (false);
public async Task<int> TestTaskGeneric ()
{
await Task.Factory.StartNew (() => {
mre_task.Set ();
mre.WaitOne (3000);
return 5;
}).ConfigureAwait (false);;
return 1;
}
public static int Main ()
{
var c = new C ();
var t2 = c.TestTaskGeneric ();
if (t2.Status != TaskStatus.WaitingForActivation)
return 1;
c.mre_task.WaitOne (3000);
c.mre.Set ();
if (!Task.WaitAll (new[] { t2 }, 3000))
return 2;
if (t2.Result != 1)
return 3;
if (t2.Status != TaskStatus.RanToCompletion)
return 4;
return 0;
}
}