[interp] Reduce computation under calc_section mutex
[mono-project.git] / mcs / tests / test-async-24.cs
blob85f6b2c904f5cef25bec8026d2b7c4e2cce5a2de
1 using System;
2 using System.Threading.Tasks;
3 using System.Threading;
5 struct Struct
7 object m_member;
8 public Struct (object member)
10 m_member = member;
13 public async Task<bool> AsyncMethod ()
15 bool b = (string)m_member == "1";
16 await Task.Factory.StartNew (() => -3);
17 b &= (string)m_member == "1";
18 return b;
22 class C
24 public static int Main ()
26 Struct s = new Struct ("1");
27 var t = s.AsyncMethod ();
28 if (!Task.WaitAll (new[] { t }, 2000))
29 return 1;
31 if (!t.Result)
32 return 2;
34 return 0;