using System; namespace Implab { public interface ICancellationToken { /// /// Indicates wherther the cancellation was requested. /// bool IsCancellationRequested { get ; } /// /// The reason why the operation should be cancelled. /// Exception CancellationReason { get ; } /// /// Accepts if requested. /// /// true, if if requested was accepted, false otherwise. bool CancelOperationIfRequested(); /// /// Sets the token to cancelled state. /// /// The reason why the operation was cancelled. void CancelOperation(Exception reason); /// /// Adds the listener for the cancellation request, is the cancellation was requested the /// is executed immediatelly. /// /// The handler which will be executed if the cancel occurs. void CancellationRequested(Action handler); } }