##// END OF EJS Templates
Implemented PollingRunnableComponent
Implemented PollingRunnableComponent

File last commit:

r196:40d7fed4a09e default
r202:2651cb9a4250 v2
Show More
FuncTaskBase.cs
52 lines | 1.5 KiB | text/x-csharp | CSharpLexer
cin
DRAFT: refactoring
r144 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 FuncTaskBase<TResult> : AbstractTask<TResult> {
cin
DRAFT: refactoring
r144 readonly Func<Exception, TResult> m_cancel;
readonly Func<Exception, TResult> m_error;
cin
fixed promises cancellation
r149 protected FuncTaskBase( Func<Exception, TResult> error, Func<Exception, TResult> cancel, bool autoCancellable) {
cin
DRAFT: refactoring
r144 m_error = error;
m_cancel = cancel;
cin
fixed promises cancellation
r149 if (autoCancellable)
CancellationRequested(CancelOperation);
cin
DRAFT: refactoring
r144 }
public void Reject(Exception error) {
Safe.ArgumentNotNull(error, "error");
if (LockCancelation())
HandleErrorInternal(error);
}
protected void HandleErrorInternal(Exception error) {
if (m_error != null) {
try {
SetResult(m_error(error));
} 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
DRAFT: refactoring
r144 }
} 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
DRAFT: refactoring
r144 }
}
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);
}
protected void HandleCancelInternal(Exception reason) {
if (m_cancel != null) {
try {
SetResult(m_cancel(reason));
} 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
DRAFT: refactoring
r144 }
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
DRAFT: refactoring
r144 }
}
}
}