linux-packaging-mono/mcs/tests/test-async-04.cs
Jo Shields 8b9b85e7f5 Imported Upstream version 3.10.0
Former-commit-id: 172c8e3c300b39d5785c7a3e8dfb08ebdbc1a99b
2014-10-04 11:27:48 +01:00

44 lines
753 B
C#

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;
}
}