Interface GatewayProgressManager
- All Superinterfaces:
ProgressManager
The GatewayProgressManager is used to execute tasks on the gateway that might take a while. The tasks are initiated
by a client (usually a designer), and updates on the task's state are fed back to the client progress system through
the gateway's push mechanism.
The running tasks publish updates by retrieving the current progress listener for their thread through the function on this interface. This method is used due to the way that methods are invoked by the client on the gateway.
The easiest way to use this system is to write a GatewayFunc annotated function, and use the "asyncInvoke" flag of that annotation. That will cause the function to be passed through this system automatically.
-
Field Summary
Fields inherited from interface com.inductiveautomation.ignition.common.gui.progress.ProgressManager
PUSH_PROTOCOL_UPDATE
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancelTask
(String taskId) Sets the canceled flag of the specified task.Returns the TaskProgressListener registered for the calling thread.getState()
Returns the current state of all running tasks.Similar torunAsyncTask(String, GatewayProgressRunnable)
, but registers a task that doesn't exist under a user session.runAsyncTask
(String sessionid, GatewayProgressRunnable task) Registers a task to run asynchronously.void
-
Method Details
-
runAsyncTask
Registers a task to run asynchronously. The provided task will be run in a different thread, who will have a threadlocal TaskProgressListener that can be updated. The registration returns a task uid that can be used to monitor the state.- Parameters:
sessionid
- the client session that is interested in the progress of this task.task
- the runnable to execute.- Returns:
- the task uid
-
runAsyncTask
Similar torunAsyncTask(String, GatewayProgressRunnable)
, but registers a task that doesn't exist under a user session. -
cancelTask
Sets the canceled flag of the specified task. The task will only be canceled if the executor watches the flag and exits.Right now unknown task ids are just ignored, but in the future we might want to throw an error. We may also want to provide some sort of feedback.
-
getProgressListenerForThread
TaskProgressListener getProgressListenerForThread()Returns the TaskProgressListener registered for the calling thread. If no listener is registered, a "dummy" listener will be returned that will discard updates.- Returns:
- a TaskProgressListener, guaranteed to not be null.
-
setProgressListenerForThread
-
getState
List<TaskProgressState> getState()Returns the current state of all running tasks.
-