Interface InterruptibleTask<ResultType>

Type Parameters:
ResultType - the type of the result of the task

public interface InterruptibleTask<ResultType>
Defines a generic task which can be canceled by interrupting the thread executing the task. The task may respond to cancellation request either by throwing an InterruptedException or an OperationCanceledException.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Executes the task defined by this InterruptibleTask.
  • Method Details

    • execute

      ResultType execute(CancellationToken cancelToken) throws InterruptedException
      Executes the task defined by this InterruptibleTask. The task may choose to detect cancellation by means of the passed CancellationToken or checking the interrupted status of the executing thread (or both).
      Parameters:
      cancelToken - the CancellationToken which can be checked to detect cancellation requests. This task may also choose to ignore this argument and check the interrupted status of the executing thread. This argument cannot be null.
      Returns:
      the return value of the task. This return value can be anything the task wishes
      Throws:
      InterruptedException - the task may throw this exception in response to a cancellation request
      OperationCanceledException - the task may throw this exception in response to a cancellation request