Merge pull request #495 from nicolas-raoul/fix-for-issue2907-with-no-formatting-changes
[mono.git] / mcs / tests / test-async-26.cs
1 // Compiler options: -langversion:future
2
3 using System;
4 using System.Threading;
5 using System.Threading.Tasks;
6
7 namespace ConsoleApplication1
8 {
9         class Program
10         {
11                 public static Task<TResult> Run<TResult> (Func<Task<TResult>> function)
12                 {
13                         var t = Task<Task<TResult>>.Factory.StartNew (function);
14                         return GetTaskResult (t);
15                 }
16
17                 async static Task<TResult> GetTaskResult<TResult> (Task<Task<TResult>> task)
18                 {
19                         return await task.Result;
20                 }
21
22                 public static int Main ()
23                 {
24                         var t2 = Run (() => Task<int>.Factory.StartNew (() => 5));
25
26                         if (!t2.Wait (1000)) {
27                                 Console.WriteLine (t2.Status);
28                                 return 1;
29                         }
30                         
31                         Console.WriteLine ("ok");
32                         return 0;
33                 }
34         }
35 }