Background open/print window results in non-refreshed data

I have a client event script that on a tag change opens a window in the background (ordered to the back), pauses 2 seconds for the data to update via custom properties, prints the window, and then closes the window. This happens essentially without any effect on the client UI other than an indication that a window is being opened. When I try to execute the same type of script from a button on a client window, the UI seems to freeze until the script is complete and the data on the printed window is not refreshed via the custom properties. I get fields with overlays on the printout and static values from when the window was developed, not the custom parameters that I opened the window with. My questions are 1. How can this script be executed without freezing the UI until complete, say on a different thread, and 2. Is there some execution strategy that guarantees that the data on the window will be refreshed prior to printing, for example some property that can be examined to ensure this behavior.

Any script that runs in event handlers on windows can cause the UI to freeze since they run in the GUI thread. You can use Ignition’s system.util.invokeAsynchronous to run your script in a different thread. Check out the following page of our user manual:

inductiveautomation.com/supp … ronous.htm

The only trick is if you want to do something back on the GUI thread you must use system.util.invokeLater. The client timer scripts already run in a separate thread.

There really isn’t any indication that the data is refreshed correctly on the popup window when you use binding. I won’t use binding in this case. Instead I would use scripting by adding a script to the Vision window opened event handler of the popup. You can run the SQL queries in there and you are guaranteed that they came back correctly. You would take the results of the SQL queries and set them to the properties on the window then print the window.