Need help understanding system.tag.writeAllSynchronous()

@lrose

The reference to the rootContainer is needed so that the functions called on the asynchronous thread can access the UI elements.

If the functions doesn't interact with the UI elements would it then still be neccesary?
It is only the pseudo-function project.show_data(parms) which sends data to a table component.
The function 'digs' down to the component using either system.gui.getWindow() or system.nav.openWindowInstance() depending on if the window is already open or not.
I'm not using the event trigger.

To use @pturmel excellent optimization suggestion you would simply call the read_data function following the write_Data and pass the results to the show function.

How is this an optimization? I realize there are a lot of thing I need to learn about asynchronous programming.

Also, since you are now doing this asynchronously and there is a guarantee that the write will happen prior to the read, there is no need for the delay in the invoke later call.

Wouldn't I still need the delay to ensure the scanclass time has passed before reading the tags after wirting to them?

And again, thank you for your replies

In this case, you don't need to pass the event or a component.

Reading tags at the client involves a round trip to the gateway. The UI hesitates if you do this on the foreground thread. The read doesn't need access the to UI elements, so it can run in the background. Once you go to the trouble to use a background thread, it is wise to use it for everything allowed. Only the assignments back to components need to be in the foreground.

1 Like