Class Task<T>
java.lang.Object
com.inductiveautomation.ignition.client.util.gui.progress.Task<T>
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptioncreate
(String name, @Nullable String description, FragileRunnable<Exception> runnable) Creates a task that wraps some runnable (returning no result).static <V> Task<V>
Creates a task that wraps some callable (returning a result).static <V> Task<V>
create
(String name, FragileFunction<TaskProgressListener, V, Exception> function) Creates a task wrapping a complex function that receives aTaskProgressListener
as an argument.getName()
runAsync
(int timeoutSeconds) Runs this task asynchronously, returning a future that will be completed when the task is done.runAsync
(int timeoutSeconds, ExecutorService executor) Runs this task asynchronously, returning a future that will be completed when the task is done.runBlocking
(int timeoutSeconds) Completes this task on the invoking thread, blocking until completion.runBlocking
(int timeoutSeconds, ExecutorService executorService) Completes this task on the invoking thread, blocking until completion.void
runInternal
(CompletableFuture<T> future, TaskProgressListener progressListener, ExecutorService executor) static void
-
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 aTaskProgressListener
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
-
runBlocking
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 completeException
- if the task itself threw an exception
-
runBlocking
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 completeException
- if the task itself threw an exception
-
runAsync
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
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
-