##// END OF EJS Templates
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler...
Reworked cancelation handling, if the cancel handler isn't specified the OperationCanceledException will be handled by the error handler Any unhandled OperationCanceledException will cause the promise cancelation

File last commit:

r145:706fccb85524 v2
r187:dd4a3590f9c6 ref20160224
Show More
ICancellationToken.cs
36 lines | 1.2 KiB | text/x-csharp | CSharpLexer
/ Implab / ICancellationToken.cs
using System;
namespace Implab {
public interface ICancellationToken {
/// <summary>
/// Indicates wherther the cancellation was requested.
/// </summary>
bool IsCancellationRequested { get ; }
/// <summary>
/// The reason why the operation should be cancelled.
/// </summary>
Exception CancellationReason { get ; }
/// <summary>
/// Accepts if requested.
/// </summary>
/// <returns><c>true</c>, if if requested was accepted, <c>false</c> otherwise.</returns>
bool CancelOperationIfRequested();
/// <summary>
/// Sets the token to cancelled state.
/// </summary>
/// <param name="reason">The reason why the operation was cancelled.</param>
void CancelOperation(Exception reason);
/// <summary>
/// Adds the listener for the cancellation request, is the cancellation was requested the <paramref name="handler"/>
/// is executed immediatelly.
/// </summary>
/// <param name="handler">The handler which will be executed if the cancel occurs.</param>
void CancellationRequested(Action<Exception> handler);
}
}