By doing nothing besides marking your function as an AsyncFunction, you’re changing the way the results get delivered, but not making much of a difference otherwise. To maintain backwards compatibility with the way Ignition used to do operations, invoking a function like this from the client will still block the EDT, and thus freeze the display. However, there is a subtle difference: if on the gateway, you get the [tt]TaskProgressListener[/tt] for the operation through [tt]GatewayContext.getProgressManager().getProgressListenerForThread()[/tt], and update it from time to time, you can prevent the operation in the client from timing out at the normal 60 second timeout.
In other words, here’s what happens:
- Normal direct RPC call: client calls to gateway on event dispatch thread, waits for result. Thread is blocked, so the UI freezes, and the socket has a timeout of 60 seconds. No matter what, if the call doesn’t return before the timeout, an error is thrown.
- Call to AsyncFunction: The function on the gateway is invoked. It returns immediately with a special token telling the client it’s an async call. The client blocks, and periodically checks for updates from the gateway task. If no updates arrive during the timeout period, and error is thrown.
- Calls invoked from [tt]ClientProgressManager.runTask[/tt]: Basically the same as #2, but started from a different thread, so the UI doesn’t block.
Right now, async tasks will cause the progress screen to be displayed. Shortly, we intend to modify the system a bit to both provide better status, and let modules opt out of this. Anyhow, hope this sorts it out for you a bit.
The AsyncClientTask is pretty much just a runnable, but the run function takes a progress listener that you can update (most useful when performing a long running task in the client that doesn’t involve the gateway, not so much for what you’re doing), as well as a title for the progress display, and a bool indicating whether the operation is cancellable. If you want to support cancelling, you need to get the progress listener on the gateway, and check isCanceled periodically during execution. If true, just stop what you’re doing.