##// END OF EJS Templates
added Safe.DispatchEvent() a legacy equivalent for '?.Invoke()'...
added Safe.DispatchEvent() a legacy equivalent for '?.Invoke()' added Safe.Dispose(IEnumerable) added PromiseExtensions.CancellationPoint to add a cancellation point to the chain of promises added IPromise<T> PromiseExtensions.Then<T>(this IPromise<T> that, Action<T> success) overloads added PromiseExtensions.Error() overloads to handle a error or(and) a cancellation

File last commit:

r196:40d7fed4a09e default
r207:558f34b2fb50 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 }
}
}
}