##// END OF EJS Templates
Added tag release v2.1 for changeset f1da3afc3521
Added tag release v2.1 for changeset f1da3afc3521

File last commit:

r187:dd4a3590f9c6 ref20160224
r193:0d69c0d6de0d default
Show More
FuncTaskBase.cs
52 lines | 1.6 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) {
HandleErrorInternal(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 {
HandleErrorInternal(reason ?? new OperationCanceledException());
cin
DRAFT: refactoring
r144 }
}
}
}