diff Implab/PromiseExtensions.cs @ 151:ec91a6dfa5b3 v2

Added support for 'await' operator to promises
author cin
date Thu, 04 Feb 2016 02:43:05 +0300
parents eb793fbbe4ea
children 822aab37b107
line wrap: on
line diff
--- a/Implab/PromiseExtensions.cs	Sat Dec 12 22:12:44 2015 +0300
+++ b/Implab/PromiseExtensions.cs	Thu Feb 04 02:43:05 2016 +0300
@@ -287,13 +287,10 @@
             
         #if NET_4_5
 
-        public static Task<T> GetTask<T>(this IPromise<T> that) {
+        public static PromiseAwaiter<T> GetAwaiter<T>(this IPromise<T> that) {
             Safe.ArgumentNotNull(that, "that");
-            var tcs = new TaskCompletionSource<T>();
 
-            that.On(tcs.SetResult, tcs.SetException, r => tcs.SetCanceled());
-
-            return tcs.Task;
+            return new PromiseAwaiter<T>(that);
         }
 
         #endif