comparison 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
comparison
equal deleted inserted replaced
137:238e15580926 138:f75cfa58e3d4
20 /// Обещание было отменено. 20 /// Обещание было отменено.
21 /// </summary> 21 /// </summary>
22 bool IsCancelled { get; } 22 bool IsCancelled { get; }
23 23
24 /// <summary> 24 /// <summary>
25 /// Исключение возникшее в результате выполнения обещания, либо причина отмены.
26 /// </summary>
27 Exception Error { get; }
28
29 /// <summary>
25 /// Creates a new promise dependend on the current one and resolved on 30 /// Creates a new promise dependend on the current one and resolved on
26 /// executing the specified handlers. 31 /// executing the specified handlers.
27 /// </summary> 32 /// </summary>
28 /// <param name="success">The handler called on the successful promise completion.</param> 33 /// <param name="success">The handler called on the successful promise completion.</param>
29 /// <param name="error">The handler is called if an error while completing the promise occurred.</param> 34 /// <param name="error">The handler is called if an error while completing the promise occurred.</param>
41 /// When the error handler is specified, the exception raised during the current promise completion 46 /// When the error handler is specified, the exception raised during the current promise completion
42 /// will be passed to it as the parameter. If the error handler returns without raising an 47 /// will be passed to it as the parameter. If the error handler returns without raising an
43 /// exception then the dependant promise will be resolved successfully, otherwise the exception 48 /// exception then the dependant promise will be resolved successfully, otherwise the exception
44 /// raised by the handler will be transmitted to the dependent promise. If the handler wants 49 /// raised by the handler will be transmitted to the dependent promise. If the handler wants
45 /// to passthrough the original exception it needs to wrap the exception with 50 /// to passthrough the original exception it needs to wrap the exception with
46 /// the <see cref="PromiseTransientException"/>. 51 /// the <see cref="PromiseTransientException"/>. The handler may raise <see cref="OperationCanceledException"/>
52 /// to cancel the dependant promise, the innner exception specifies the reason why the promise
53 /// is canceled.
47 /// </para> 54 /// </para>
48 /// <para> 55 /// <para>
49 /// If the cancelation handler is specified and the current promise is cancelled then the dependent 56 /// If the cancelation handler is specified and the current promise is cancelled then the dependent
50 /// promise will be resolved after the handler is executed. If the cancelation hendler raises the 57 /// promise will be resolved after the handler is executed. If the cancelation handler raises the
51 /// exception it will be passed to the dependent promise. 58 /// exception it will be passed to the dependent promise.
52 /// </para> 59 /// </para>
53 /// </remarks> 60 /// </remarks>
54 IPromise Then(Action success, Action<Exception> error, Action cancel); 61 IPromise Then(Action success, Action<Exception> error, Action<Exception> cancel);
55 IPromise Then(Action success, Action<Exception> error); 62 IPromise Then(Action success, Action<Exception> error);
56 IPromise Then(Action success); 63 IPromise Then(Action success);
57 64
58 IPromise Chain(Func<IPromise> chained, Func<Exception, IPromise> error, Func<IPromise> cancel); 65 IPromise Chain(Func<IPromise> chained, Func<Exception, IPromise> error, Func<Exception, IPromise> cancel);
59 IPromise Chain(Func<IPromise> chained, Func<Exception, IPromise> error); 66 IPromise Chain(Func<IPromise> chained, Func<Exception, IPromise> error);
60 IPromise Chain(Func<IPromise> chained); 67 IPromise Chain(Func<IPromise> chained);
61 68
62 /// <summary> 69 /// <summary>
63 /// Adds specified listeners to the current promise. 70 /// Adds specified listeners to the current promise.
64 /// </summary> 71 /// </summary>
65 /// <param name="success">The handler called on the successful promise completion.</param> 72 /// <param name="success">The handler called on the successful promise completion.</param>
66 /// <param name="error">The handler is called if an error while completing the promise occurred.</param> 73 /// <param name="error">The handler is called if an error while completing the promise occurred.</param>
67 /// <param name="cancel">The handler is called in case of promise cancellation.</param> 74 /// <param name="cancel">The handler is called in case of promise cancellation.</param>
68 /// <returns>The current promise.</returns> 75 /// <returns>The current promise.</returns>
69 IPromise On(Action success, Action<Exception> error, Action cancel); 76 IPromise On(Action success, Action<Exception> error, Action<Exception> cancel);
70 IPromise On(Action success, Action<Exception> error); 77 IPromise On(Action success, Action<Exception> error);
71 IPromise On(Action success); 78 IPromise On(Action success);
72 79
73 /// <summary> 80 /// <summary>
74 /// Adds specified listeners to the current promise. 81 /// Adds specified listeners to the current promise.
76 /// <param name="handler">The handler called on the specified events.</param> 83 /// <param name="handler">The handler called on the specified events.</param>
77 /// <param name = "events">The combination of flags denoting the events for which the 84 /// <param name = "events">The combination of flags denoting the events for which the
78 /// handler shoud be called.</param> 85 /// handler shoud be called.</param>
79 /// <returns>The current promise.</returns> 86 /// <returns>The current promise.</returns>
80 IPromise On(Action handler, PromiseEventType events); 87 IPromise On(Action handler, PromiseEventType events);
81
82 /// <summary>
83 /// Adds the specified error handler to the current promise
84 /// and creates the new dependant promise.
85 /// </summary>
86 /// <param name="error">
87 /// The error handler. If the error handler returns without
88 /// an error the dependant promise will be successfully resolved.
89 /// </param>
90 /// <returns>
91 /// The new dependant promise which will be resolved after the error
92 /// handler is executed.
93 /// </returns>
94 /// <remarks>
95 /// The successfull result of the current promise will be ignored.
96 /// </remarks>
97 IPromise Error(Action<Exception> error);
98
99 /// <summary>
100 /// Adds the specified cncellation handler to the current promise
101 /// and creates the new dependant promise.
102 /// </summary>
103 /// <returns>
104 /// The new dependant promise which will be resolved after the cancellation
105 /// handler is executed.
106 /// </returns>
107 /// <param name="handler">
108 /// The cancellation handler.
109 /// </param>
110 /// <remarks>
111 /// If the cancellation handler is executed without an error the dependent
112 /// promise will be successfully resolved, otherwise the raised exception
113 /// will be passed to the dependant promise. The successful result of the
114 /// current promise will be ignored.
115 /// </remarks>
116 IPromise Cancelled(Action handler);
117 88
118 /// <summary> 89 /// <summary>
119 /// Преобразует результат обещания к заданному типу и возвращает новое обещание. 90 /// Преобразует результат обещания к заданному типу и возвращает новое обещание.
120 /// </summary> 91 /// </summary>
121 IPromise<T> Cast<T>(); 92 IPromise<T> Cast<T>();