[ilasm] Don't break arguments compatiblity
[mono-project.git] / mcs / tests / test-async-07.cs
blob60c4ca000ef082502c339703ec1568d75cb37c09
1 using System;
2 using System.Threading;
3 using System.Threading.Tasks;
5 class Program
7 public static int Main ()
9 var mre_l = new ManualResetEvent (false);
10 var mre = new ManualResetEvent (false);
12 Func<string, Task<string>> f = async l =>
13 await Task.Factory.StartNew (() => {
14 if (!mre_l.WaitOne (3000))
15 throw new ApplicationException ("3");
17 return l;
18 }).ConfigureAwait (false);
20 var r = f ("a");
21 mre_l.Set ();
22 if (!r.Wait (3000))
23 return 1;
25 if (r.Result != "a")
26 return 11;
28 mre_l.Reset ();
30 Func<Task> ff = async () =>
31 await Task.Factory.StartNew (() => {
32 if (!mre_l.WaitOne (3000))
33 throw new ApplicationException ("3");
34 }).ConfigureAwait (false);
36 var rr = ff ();
37 mre_l.Set ();
38 if (!rr.Wait (3000))
39 return 2;
41 Func<short, Task<short>> f2 = async l => l;
43 var r2 = f2 (88);
44 if (r2.Result != 88)
45 return 3;
47 mre.Reset ();
48 mre_l.Reset ();
49 Action a = async () => await Task.Factory.StartNew (() => {
50 if (!mre_l.WaitOne (3000))
51 throw new ApplicationException ("4");
52 mre.Set ();
53 }, CancellationToken.None).ConfigureAwait (false);
55 a ();
56 mre_l.Set ();
57 if (!mre.WaitOne (3000))
58 return 4;
60 Console.WriteLine ("ok");
61 return 0;