Mercurial > pub > ImplabNet
comparison Implab/PromiseExtensions.cs @ 104:5f10d54b45df v2
renamed Promise.Last -> Promise.On
Promise.On doesn't changes Promise.IsExclusive property
| author | cin |
|---|---|
| date | Sun, 09 Nov 2014 23:03:45 +0300 |
| parents | 279e226dffdd |
| children | 1b7ebcc52e5a |
comparison
equal
deleted
inserted
replaced
| 103:b3f5bc613905 | 104:5f10d54b45df |
|---|---|
| 12 if (context == null) | 12 if (context == null) |
| 13 return that; | 13 return that; |
| 14 | 14 |
| 15 var p = new SyncContextPromise<T>(context, that); | 15 var p = new SyncContextPromise<T>(context, that); |
| 16 | 16 |
| 17 that.Last( | 17 that.On( |
| 18 p.Resolve, | 18 p.Resolve, |
| 19 p.Reject, | 19 p.Reject, |
| 20 p.Cancel | 20 p.Cancel |
| 21 ); | 21 ); |
| 22 return p; | 22 return p; |
| 26 Safe.ArgumentNotNull(that, "that"); | 26 Safe.ArgumentNotNull(that, "that"); |
| 27 Safe.ArgumentNotNull(context, "context"); | 27 Safe.ArgumentNotNull(context, "context"); |
| 28 | 28 |
| 29 var p = new SyncContextPromise<T>(context, that); | 29 var p = new SyncContextPromise<T>(context, that); |
| 30 | 30 |
| 31 that.Last( | 31 that.On( |
| 32 p.Resolve, | 32 p.Resolve, |
| 33 p.Reject, | 33 p.Reject, |
| 34 p.Cancel | 34 p.Cancel |
| 35 ); | 35 ); |
| 36 return p; | 36 return p; |
| 47 /// <typeparam name="T">The 2nd type parameter.</typeparam> | 47 /// <typeparam name="T">The 2nd type parameter.</typeparam> |
| 48 public static TPromise EnsureDispatched<TPromise,T>(this TPromise that, IPromise<T> head, Action<T> cleanup) where TPromise : IPromise{ | 48 public static TPromise EnsureDispatched<TPromise,T>(this TPromise that, IPromise<T> head, Action<T> cleanup) where TPromise : IPromise{ |
| 49 Safe.ArgumentNotNull(that, "that"); | 49 Safe.ArgumentNotNull(that, "that"); |
| 50 Safe.ArgumentNotNull(head, "head"); | 50 Safe.ArgumentNotNull(head, "head"); |
| 51 | 51 |
| 52 that.Last(null,null,() => head.Last(cleanup)); | 52 that.On(null,null,() => head.On(cleanup)); |
| 53 | 53 |
| 54 return that; | 54 return that; |
| 55 } | 55 } |
| 56 | 56 |
| 57 public static AsyncCallback AsyncCallback<T>(this Promise<T> that, Func<IAsyncResult,T> callback) { | 57 public static AsyncCallback AsyncCallback<T>(this Promise<T> that, Func<IAsyncResult,T> callback) { |
| 70 | 70 |
| 71 public static Task<T> GetTask<T>(this IPromise<T> that) { | 71 public static Task<T> GetTask<T>(this IPromise<T> that) { |
| 72 Safe.ArgumentNotNull(that, "that"); | 72 Safe.ArgumentNotNull(that, "that"); |
| 73 var tcs = new TaskCompletionSource<T>(); | 73 var tcs = new TaskCompletionSource<T>(); |
| 74 | 74 |
| 75 that.Last(tcs.SetResult, tcs.SetException, tcs.SetCanceled); | 75 that.On(tcs.SetResult, tcs.SetException, tcs.SetCanceled); |
| 76 | 76 |
| 77 return tcs.Task; | 77 return tcs.Task; |
| 78 } | 78 } |
| 79 | 79 |
| 80 #endif | 80 #endif |
