##// END OF EJS Templates
RunnableComponent.Dispose(bool,Exception) changed to standart Dispose(bool)...
RunnableComponent.Dispose(bool,Exception) changed to standart Dispose(bool) IRunnable is now disposable Code cleanups, suppressed some CodeAnalysis warnings

File last commit:

r196:40d7fed4a09e default
r208:7d07503621fe v2
Show More
FuncChainTaskBase.cs
54 lines | 1.8 KiB | text/x-csharp | CSharpLexer
/ Implab / FuncChainTaskBase.cs
cin
RC: cancellation support for promises + tests
r145 using System;
namespace Implab {
cin
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler...
r187 public class FuncChainTaskBase<TResult> : AbstractTask<TResult> {
cin
RC: cancellation support for promises + tests
r145 readonly Func<Exception, IPromise<TResult>> m_error;
readonly Func<Exception, IPromise<TResult>> m_cancel;
cin
fixed promises cancellation
r149 protected FuncChainTaskBase( Func<Exception, IPromise<TResult>> error, Func<Exception, IPromise<TResult>> cancel, bool autoCancellable) {
cin
RC: cancellation support for promises + tests
r145 m_error = error;
m_cancel = cancel;
cin
fixed promises cancellation
r149 if (autoCancellable)
CancellationRequested(CancelOperation);
cin
RC: cancellation support for promises + tests
r145 }
public void Reject(Exception error) {
if (LockCancelation())
HandleErrorInternal(error);
}
public override void CancelOperation(Exception reason) {
cin
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler...
r187 if (LockCancelation())
HandleCancelInternal(reason);
cin
RC: cancellation support for promises + tests
r145 }
protected void HandleErrorInternal(Exception error) {
if (m_error != null) {
try {
cin
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler...
r187 var p = m_error(error);
p.On(SetResult, SetErrorInternal, SetCancelledInternal);
CancellationRequested(p.Cancel);
cin
RC: cancellation support for promises + tests
r145 } catch(Exception err) {
cin
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler...
r187 SetErrorInternal(err);
cin
RC: cancellation support for promises + tests
r145 }
} else {
cin
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler...
r187 SetErrorInternal(error);
cin
RC: cancellation support for promises + tests
r145 }
}
cin
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler...
r187 protected void HandleCancelInternal(Exception reason) {
if (m_cancel != null) {
try {
var p = m_cancel(reason);
p.On(SetResult, HandleErrorInternal, SetCancelledInternal);
CancellationRequested(p.Cancel);
} catch (Exception err) {
cin
fixed promise chaining behavior, the error handler doesn't handle result or cancellation handlers exceptions these exceptions are propagated to the next handlers.
r196 SetErrorInternal(err);
cin
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler...
r187 }
} else {
cin
fixed promise chaining behavior, the error handler doesn't handle result or cancellation handlers exceptions these exceptions are propagated to the next handlers.
r196 SetCancelledInternal(reason);
cin
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler...
r187 }
cin
RC: cancellation support for promises + tests
r145 }
}
}