##// END OF EJS Templates
minor changes
minor changes

File last commit:

r187:dd4a3590f9c6 ref20160224
r195:ea485487a424 v2
Show More
ActionTaskBase.cs
53 lines | 1.6 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) {
HandleErrorInternal(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 {
HandleErrorInternal(error ?? new OperationCanceledException());
cin
RC: cancellation support for promises + tests
r145 }
}
}
}