Mercurial > pub > ImplabNet
diff Implab/PromiseExtensions.cs @ 138:f75cfa58e3d4 v2
added ICancellable.Cancel(Exception) to allow specify the reason of cancellation
author | cin |
---|---|
date | Tue, 17 Feb 2015 18:16:26 +0300 |
parents | e9e7940c7d98 |
children | 706fccb85524 |
line wrap: on
line diff
--- a/Implab/PromiseExtensions.cs Mon Feb 16 17:48:39 2015 +0300 +++ b/Implab/PromiseExtensions.cs Tue Feb 17 18:16:26 2015 +0300 @@ -56,7 +56,7 @@ Safe.ArgumentNotNull(that, "that"); Safe.ArgumentNotNull(head, "head"); - that.On(null,null,() => head.On(cleanup)); + that.On(() => head.On(cleanup), PromiseEventType.Cancelled); return that; } @@ -123,9 +123,9 @@ new Exception("The dependency promise is failed", error) ); }, - () => { + reason => { if (Interlocked.Increment(ref errors) == 1) - medium.Reject( + medium.Cancel( new Exception("The dependency promise is cancelled") ); } @@ -162,10 +162,10 @@ new Exception("The dependency promise is failed", error) ); }, - () => { + reason => { if (Interlocked.Increment(ref errors) == 1) - medium.Reject( - new Exception("The dependency promise is cancelled") + medium.Cancel( + new Exception("The dependency promise is cancelled", reason) ); } ); @@ -181,7 +181,7 @@ Safe.ArgumentNotNull(that, "that"); var tcs = new TaskCompletionSource<T>(); - that.On(tcs.SetResult, tcs.SetException, tcs.SetCanceled); + that.On(tcs.SetResult, tcs.SetException, r => tcs.SetCanceled()); return tcs.Task; }