Interface CancellationController


public interface CancellationController
Defines an interface to cancel an asynchronously executing task. The CancellationController is usually associated with a CancellationToken sharing the same CancellationSource. In this case the associated CancellationToken will signal that cancellation was requested after the cancel() method has been called.

Canceling a task is an idempotent action (that is, canceling it multiple times has no further effect).

Thread safety

Implementations of this interface must be safe to be accessed by multiple threads concurrently.

Synchronization transparency

The cancel() method of this interface is not required to be synchronization transparent but it must not execute expensive computations and must not wait for external events (such as an IO operation).
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Requests that the associated task be canceled.
  • Method Details

    • cancel

      void cancel()
      Requests that the associated task be canceled. When and, if the task will actually be canceled depends on the task but tasks should terminate as soon as possible when they detect that cancellation was requested.

      If this CancellationController is associated with a CancellationToken, this method may need to invoke the listeners registered to listen for cancellation requests. In case they throw any unchecked exception (although reasonable listener should not), the exception may be propagated to the caller of this method.

      This method is idempotent (that is, canceling it multiple times has no further effect).