Class TaskLauncher
For complete control of how this class functions, use
TaskLauncher(Task, Component, int, int)
. Alternatively, for simpler uses,
see one of the many static convenience methods.
Component
. Further, if you task is modal, then the
progress dialog should always be shown over the active window so that users understand that
their UI is blocked. In this case, there is no need to specify a component over which to
show the dialog.
An alternative to using this class is to use the TaskBuilder
, which offers a
more Fluent API approach for your tasking needs.
-
Constructor Summary
ConstructorDescriptionTaskLauncher
(Task task) Constructor for TaskLauncherTaskLauncher
(Task task, Component parent) Constructor for TaskLauncherTaskLauncher
(Task task, Component parent, int delayMs) Construct a new TaskLauncherTaskLauncher
(Task task, Component parent, int delayMs, int dialogWidth) Construct a new TaskLauncher -
Method Summary
Modifier and TypeMethodDescriptionprotected ghidra.util.task.TaskRunner
createTaskRunner
(Task task, Component parent, int delayMs, int dialogWidth) static <T extends Task>
Tlaunch
(T task) Directly launches aTask
via a newTaskLauncher
instance, with a progress dialog.static void
launchModal
(String title, MonitoredRunnable runnable) A convenience method to directly run aMonitoredRunnable
in a separate thread as aTask
, displaying a modal progress dialog.static void
launchModal
(String title, Runnable runnable) static void
launchNonModal
(String title, MonitoredRunnable runnable) A convenience method to directly run aMonitoredRunnable
in a separate thread as aTask
, displaying a non-modal progress dialog.
-
Constructor Details
-
TaskLauncher
Constructor for TaskLauncherThis constructor assumes that if a progress dialog is needed, then it should appear over the active window. If you should need a dialog to appear over a non-active window, then either specify that window or a component within that window by calling a constructor that takes in a
Component
.- Parameters:
task
- task to run in another thread (other than the Swing Thread)
-
TaskLauncher
Constructor for TaskLauncher- Parameters:
task
- task to run in another thread (other than the Swing Thread)parent
- component whose window to use to parent the dialog.
-
TaskLauncher
Construct a new TaskLauncher- Parameters:
task
- task to run in another thread (other than the Swing Thread)parent
- component whose window to use to parent the dialog; null centers the task dialog over the current windowdelayMs
- number of milliseconds to delay until the task monitor is displayed
-
TaskLauncher
Construct a new TaskLauncher- Parameters:
task
- task to run in another thread (other than the Swing Thread)parent
- component whose window to use to parent the dialog; null centers the task dialog over the current windowdelayMs
- number of milliseconds to delay until the task monitor is displayeddialogWidth
- The preferred width of the dialog (this allows clients to make a wider dialog, which better shows long messages).
-
-
Method Details
-
launch
Directly launches aTask
via a newTaskLauncher
instance, with a progress dialog.See also
TaskLauncher(Task, Component)
-
launchNonModal
A convenience method to directly run aMonitoredRunnable
in a separate thread as aTask
, displaying a non-modal progress dialog.TaskLauncher.launchNonModal("My task", null, // parent monitor -> { while (!monitor.isCanceled()) { longRunningWork(); } } );
Note: the task created by this call will be both cancellable and have progress. If you task cannot be cancelled or does not have progress, then do not use this convenience method, but rather call one of the constructors of this class.
- Parameters:
title
- name of the task thread that will be executing this task.runnable
-MonitoredRunnable
that takes aTaskMonitor
.
-
launchModal
A convenience method to directly run aMonitoredRunnable
in a separate thread as aTask
, displaying a modal progress dialog.TaskLauncher.launchModal("My task", null, // parent monitor -> { while (!monitor.isCanceled()) { longRunningWork(); } } );
Note: the task created by this call will be both cancellable and have progress. If you task cannot be cancelled or does not have progress, then do not use this convenience method, but rather call one of the constructors of this class or
launchModal(String, MonitoredRunnable)
.- Parameters:
title
- name of the task thread that will be executing this task.runnable
-MonitoredRunnable
that takes aTaskMonitor
.
-
launchModal
A convenience method to directly run aRunnable
in a separate thread as aTask
, displaying a non-modal progress dialog.This modal will be launched immediately, without delay. Typically the launcher will delay showing the modal dialog in order to prevent the dialog from being shown, just to have it immediately go away. If you desire this default behavior, then do not use this convenience method.
TaskLauncher.launchModal("My task", monitor -> { foo(); } );
Note: the task created by this call will not be cancellable nor have progress. If you need either of these behaviors, the do not use this convenience method, but rather call one of the constructors of this class.
- Parameters:
title
- name of the task thread that will be executing this task.runnable
-Runnable
to be called in a background thread
-
createTaskRunner
-