[LoongArch64] Part-5:add loongarch support in some files for LoongArch64. (#21769)
[mono-project.git] / mcs / tests / test-async-01.cs
blobcc9271c9353dbd276f45c69281eb1e27e5abf925
1 using System;
2 using System.Threading;
3 using System.Threading.Tasks;
5 class Program
7 static ManualResetEvent master_mre = new ManualResetEvent (false);
8 static ManualResetEvent async_mre = new ManualResetEvent (false);
10 static int pos;
12 public static int Main ()
14 pos = 0;
15 TestAsync ();
17 if (pos != 1)
18 throw new ApplicationException (pos.ToString ());
20 pos = 2;
22 master_mre.Set ();
24 if (!async_mre.WaitOne (3000))
25 return 1;
27 if (pos != 4)
28 throw new ApplicationException (pos.ToString ());
30 return 0;
33 static async void TestAsync ()
35 pos = 1;
37 await RunAsync ().ConfigureAwait (false);
39 if (pos != 3)
40 throw new ApplicationException (pos.ToString ());
42 pos = 4;
43 async_mre.Set ();
46 static Task RunAsync ()
48 return Task.Factory.StartNew (() => {
49 master_mre.WaitOne ();
50 Console.WriteLine ("Hello async");
51 if (pos != 2)
52 throw new ApplicationException (pos.ToString ());
54 pos = 3;
55 });