Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-async-21.cs
1 using System;
2 using System.Threading.Tasks;
3 using System.Runtime.CompilerServices;
4
5 class S
6 {
7         public A GetAwaiter ()
8         {
9                 return new A ();
10         }
11 }
12
13 class A : INotifyCompletion
14 {
15         bool IsCompleted {
16                 get {
17                         return false;
18                 }
19         }
20         
21         void INotifyCompletion.OnCompleted (Action a)
22         {
23                 a ();
24         }
25         
26         int GetResult ()
27         {
28                 return 3;
29         }
30         
31         static async Task<int> Test1 ()
32         {
33                 dynamic d = new S ();
34                 return await d;
35         }
36
37         public static int Main ()
38         {
39                 var r = Test1 ();
40                 if (!Task.WaitAll (new [] { r }, 1000))
41                         return 1;
42                 
43                 Console.WriteLine ("ok");
44                 return 0;
45         }
46 }