Mercurial > pub > ImplabNet
diff Implab/PromiseExtensions.cs @ 101:279e226dffdd v2
code cleanup
added EnsureDispatched extension
author | cin |
---|---|
date | Thu, 06 Nov 2014 20:03:19 +0300 |
parents | c761fc982e1d |
children | 5f10d54b45df |
line wrap: on
line diff
--- a/Implab/PromiseExtensions.cs Wed Nov 05 16:39:56 2014 +0300 +++ b/Implab/PromiseExtensions.cs Thu Nov 06 20:03:19 2014 +0300 @@ -12,7 +12,7 @@ if (context == null) return that; - var p = new SyncContextPromise<T>(context, that, true); + var p = new SyncContextPromise<T>(context, that); that.Last( p.Resolve, @@ -26,7 +26,7 @@ Safe.ArgumentNotNull(that, "that"); Safe.ArgumentNotNull(context, "context"); - var p = new SyncContextPromise<T>(context, that, true); + var p = new SyncContextPromise<T>(context, that); that.Last( p.Resolve, @@ -36,6 +36,24 @@ return p; } + /// <summary> + /// Ensures the dispatched. + /// </summary> + /// <returns>The dispatched.</returns> + /// <param name="that">That.</param> + /// <param name="head">Head.</param> + /// <param name="cleanup">Cleanup.</param> + /// <typeparam name="TPromise">The 1st type parameter.</typeparam> + /// <typeparam name="T">The 2nd type parameter.</typeparam> + public static TPromise EnsureDispatched<TPromise,T>(this TPromise that, IPromise<T> head, Action<T> cleanup) where TPromise : IPromise{ + Safe.ArgumentNotNull(that, "that"); + Safe.ArgumentNotNull(head, "head"); + + that.Last(null,null,() => head.Last(cleanup)); + + return that; + } + public static AsyncCallback AsyncCallback<T>(this Promise<T> that, Func<IAsyncResult,T> callback) { Safe.ArgumentNotNull(that, "that"); Safe.ArgumentNotNull(callback, "callback");