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

37 lines
539 B
C#

using System;
using System.Threading.Tasks;
using System.Threading;
struct Struct
{
object m_member;
public Struct (object member)
{
m_member = member;
}
public async Task<bool> AsyncMethod ()
{
bool b = (string)m_member == "1";
await Task.Factory.StartNew (() => -3);
b &= (string)m_member == "1";
return b;
}
}
class C
{
public static int Main ()
{
Struct s = new Struct ("1");
var t = s.AsyncMethod ();
if (!Task.WaitAll (new[] { t }, 2000))
return 1;
if (!t.Result)
return 2;
return 0;
}
}