##// END OF EJS Templates
Bound promise to CancellationToken...
Bound promise to CancellationToken Added new states to ExecutionSate enum. Added Safe.Guard() method to handle cleanup of the result of the promise

File last commit:

r196:40d7fed4a09e default
r209:a867536c68fc v2
Show More
ActionTaskBase.cs
53 lines | 1.5 KiB | text/x-csharp | CSharpLexer
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 ActionTaskBase : AbstractTask {
cin
RC: cancellation support for promises + tests
r145 readonly Action<Exception> m_cancel;
readonly Action<Exception> m_error;
cin
fixed promises cancellation
r149 protected ActionTaskBase( Action<Exception> error, Action<Exception> 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) {
Safe.ArgumentNotNull(error, "error");
if (LockCancelation())
HandleErrorInternal(error);
}
cin
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler...
r187 public override void CancelOperation(Exception reason) {
if (LockCancelation())
HandleCancelInternal(reason);
}
cin
RC: cancellation support for promises + tests
r145 protected void HandleErrorInternal(Exception error) {
if (m_error != null) {
try {
m_error(error);
SetResult();
} 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 error) {
if (m_cancel != null) {
try {
m_cancel(error);
SetResult();
} 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
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 } 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(error);
cin
RC: cancellation support for promises + tests
r145 }
}
}
}