Mercurial > pub > ImplabNet
diff Implab/IPromise.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 | 2573b562e328 |
children | 8c0b95069066 |
line wrap: on
line diff
--- a/Implab/IPromise.cs Mon Feb 16 17:48:39 2015 +0300 +++ b/Implab/IPromise.cs Tue Feb 17 18:16:26 2015 +0300 @@ -22,6 +22,11 @@ bool IsCancelled { get; } /// <summary> + /// Исключение возникшее в результате выполнения обещания, либо причина отмены. + /// </summary> + Exception Error { get; } + + /// <summary> /// Creates a new promise dependend on the current one and resolved on /// executing the specified handlers. /// </summary> @@ -43,19 +48,21 @@ /// exception then the dependant promise will be resolved successfully, otherwise the exception /// raised by the handler will be transmitted to the dependent promise. If the handler wants /// to passthrough the original exception it needs to wrap the exception with - /// the <see cref="PromiseTransientException"/>. + /// the <see cref="PromiseTransientException"/>. The handler may raise <see cref="OperationCanceledException"/> + /// to cancel the dependant promise, the innner exception specifies the reason why the promise + /// is canceled. /// </para> /// <para> /// If the cancelation handler is specified and the current promise is cancelled then the dependent - /// promise will be resolved after the handler is executed. If the cancelation hendler raises the + /// promise will be resolved after the handler is executed. If the cancelation handler raises the /// exception it will be passed to the dependent promise. /// </para> /// </remarks> - IPromise Then(Action success, Action<Exception> error, Action cancel); + IPromise Then(Action success, Action<Exception> error, Action<Exception> cancel); IPromise Then(Action success, Action<Exception> error); IPromise Then(Action success); - IPromise Chain(Func<IPromise> chained, Func<Exception, IPromise> error, Func<IPromise> cancel); + IPromise Chain(Func<IPromise> chained, Func<Exception, IPromise> error, Func<Exception, IPromise> cancel); IPromise Chain(Func<IPromise> chained, Func<Exception, IPromise> error); IPromise Chain(Func<IPromise> chained); @@ -66,7 +73,7 @@ /// <param name="error">The handler is called if an error while completing the promise occurred.</param> /// <param name="cancel">The handler is called in case of promise cancellation.</param> /// <returns>The current promise.</returns> - IPromise On(Action success, Action<Exception> error, Action cancel); + IPromise On(Action success, Action<Exception> error, Action<Exception> cancel); IPromise On(Action success, Action<Exception> error); IPromise On(Action success); @@ -80,42 +87,6 @@ IPromise On(Action handler, PromiseEventType events); /// <summary> - /// Adds the specified error handler to the current promise - /// and creates the new dependant promise. - /// </summary> - /// <param name="error"> - /// The error handler. If the error handler returns without - /// an error the dependant promise will be successfully resolved. - /// </param> - /// <returns> - /// The new dependant promise which will be resolved after the error - /// handler is executed. - /// </returns> - /// <remarks> - /// The successfull result of the current promise will be ignored. - /// </remarks> - IPromise Error(Action<Exception> error); - - /// <summary> - /// Adds the specified cncellation handler to the current promise - /// and creates the new dependant promise. - /// </summary> - /// <returns> - /// The new dependant promise which will be resolved after the cancellation - /// handler is executed. - /// </returns> - /// <param name="handler"> - /// The cancellation handler. - /// </param> - /// <remarks> - /// If the cancellation handler is executed without an error the dependent - /// promise will be successfully resolved, otherwise the raised exception - /// will be passed to the dependant promise. The successful result of the - /// current promise will be ignored. - /// </remarks> - IPromise Cancelled(Action handler); - - /// <summary> /// Преобразует результат обещания к заданному типу и возвращает новое обещание. /// </summary> IPromise<T> Cast<T>();