2 using System
.Threading
;
3 using System
.Threading
.Tasks
;
5 namespace ConsoleApplication1
9 public static Task
<TResult
> Run
<TResult
> (Func
<Task
<TResult
>> function
)
11 var t
= Task
<Task
<TResult
>>.Factory
.StartNew (function
);
12 return GetTaskResult (t
);
15 async static Task
<TResult
> GetTaskResult
<TResult
> (Task
<Task
<TResult
>> task
)
17 return await task
.Result
;
20 public static int Main ()
22 var t2
= Run (() => Task
<int>.Factory
.StartNew (() => 5));
24 if (!t2
.Wait (1000)) {
25 Console
.WriteLine (t2
.Status
);
29 Console
.WriteLine ("ok");