java.lang.Object
com.inductiveautomation.ignition.client.util.gui.progress.Task<T>

public final class Task<T> extends Object
  • Method Details

    • create

      public static <V> Task<V> create(String name, FragileFunction<TaskProgressListener,V,Exception> function)
      Creates a task wrapping a complex function that receives a TaskProgressListener as an argument. This argument can be used to report incremental progress, set a note, or check if the task has been canceled.
      Parameters:
      name - The name of the task, suitable for display in UI.
      See Also:
    • create

      public static <V> Task<V> create(String name, @Nullable @Nullable String description, Callable<V> callable)
      Creates a task that wraps some callable (returning a result).
      Parameters:
      name - The name of the task, suitable for display in UI.
      description - An optional description of the task, suitable for display in UI.
      Returns:
      A task that wraps the callable.
      See Also:
    • create

      public static Task<Void> create(String name, @Nullable @Nullable String description, FragileRunnable<Exception> runnable)
      Creates a task that wraps some runnable (returning no result).
      Parameters:
      name - The name of the task, suitable for display in UI.
      description - An optional description of the task, suitable for display in UI.
      Returns:
      A task that wraps the runnable.
      See Also:
    • setProgressListenerFactory

      public static void setProgressListenerFactory(Task.ProgressListenerFactory factory)
    • runBlocking

      public T runBlocking(int timeoutSeconds) throws Exception
      Completes this task on the invoking thread, blocking until completion. If the invoking thread is the EDT, a modal dialog will be shown to the user. This method will use the default executor.
      Parameters:
      timeoutSeconds - the maximum time to wait for the task to complete. If -1, wait indefinitely.
      Throws:
      InterruptedException - if the thread was interrupted while waiting for the task to complete
      Exception - if the task itself threw an exception
    • runBlocking

      public T runBlocking(int timeoutSeconds, ExecutorService executorService) throws Exception
      Completes this task on the invoking thread, blocking until completion. If the invoking thread is the EDT, a modal dialog will be shown to the user.
      Parameters:
      timeoutSeconds - the maximum time to wait for the task to complete. If -1, wait indefinitely.
      executorService - An executor to run the actual blocking task work on.
      Throws:
      InterruptedException - if the thread was interrupted while waiting for the task to complete
      Exception - if the task itself threw an exception
    • runAsync

      public CompletableFuture<T> runAsync(int timeoutSeconds)
      Runs this task asynchronously, returning a future that will be completed when the task is done. This method will use the default executor.
      Parameters:
      timeoutSeconds - the maximum time to wait for the task to complete. If -1, wait indefinitely.
    • runAsync

      public CompletableFuture<T> runAsync(int timeoutSeconds, ExecutorService executor)
      Runs this task asynchronously, returning a future that will be completed when the task is done.
      Parameters:
      timeoutSeconds - the maximum time to wait for the task to complete. If -1, wait indefinitely.
      executor - An executor to run the task on
    • runInternal

      public void runInternal(CompletableFuture<T> future, TaskProgressListener progressListener, ExecutorService executor)
    • getName

      public String getName()