I currently have a progress bar and table that is updated with an asynchronous thread. So far, the only way I’ve found to add PLC tags to a table is to manually loop through a data set in the script. Since this takes awhile, I use a progress bar to show the user that it’s running. It seems to be working just fine, however; I found a support page(posted below) which specifically says not to use the asynchronous threading to set and get component properties. If I continue to use this, will it cause problems with my screen? If so, is there a way around this?
Java’s UI toolkit, Swing, is single-threaded (like pretty much all UI toolkits). It’s not thread safe. If you interact with UI components from another thread you risk race conditions, data visibility issues, and pretty much any other concern you might have when dealing with multithreading. It might seem like it works most of the time but eventually it won’t.
The only safe approach is to move any interaction with the UI back onto the single thread the UI runs on (the Event Dispatch Thread). This is done using
system.util.invokeLater, as the documentation you linked to suggests.
Take a look at this thread and the
assignLater() utility function in later.py.
Check out this article on the subject: Understanding Threading, system.util.invokeAsynchronous in Ignition
Thanks for all the help! This has been very informative for me. I went ahead and moved my components into the invoke later command and everything is working perfectly.