# Why can't asynchronous threading be used with components?

**URL:** <https://forum.inductiveautomation.com/t/why-cant-asynchronous-threading-be-used-with-components/15103>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [August 17, 2017, 9:56pm UTC](https://forum.inductiveautomation.com/t/why-cant-asynchronous-threading-be-used-with-components/15103 "2017-08-17T21:56:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![d.koelzer](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@d.koelzer](https://forum.inductiveautomation.com/u/d.koelzer)\
**Post date:** [August 17, 2017, 9:56pm UTC](https://forum.inductiveautomation.com/t/why-cant-asynchronous-threading-be-used-with-components/15103/1 "2017-08-17T21:56:58Z")

</div>

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?

[https://support.inductiveautomation.com/usermanuals/ignition/index.html?system\_util\_invokeasynchronous.htm](https://support.inductiveautomation.com/usermanuals/ignition/index.html?system_util_invokeasynchronous.htm)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 17, 2017, 10:34pm UTC](https://forum.inductiveautomation.com/t/why-cant-asynchronous-threading-be-used-with-components/15103/2 "2017-08-17T22:34:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 18, 2017, 1:20pm UTC](https://forum.inductiveautomation.com/t/why-cant-asynchronous-threading-be-used-with-components/15103/3 "2017-08-18T13:20:05Z")

</div>

Take a look at [this thread](http://forum.inductiveautomation.com/t/update-gui-via-asynchronous-thread/9666) and the `assignLater()` utility function in later.py.

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [August 18, 2017, 2:02pm UTC](https://forum.inductiveautomation.com/t/why-cant-asynchronous-threading-be-used-with-components/15103/4 "2017-08-18T14:02:01Z")

</div>

Check out this article on the subject: [Understanding Threading, system.util.invokeAsynchronous in Ignition](http://nickmudge.info/post/understanding-threading-system.util.invokelater-and-system.util.invokeasynchronous-in-Ignition)

---

<div class="post-metadata">

**Author:** ![d.koelzer](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@d.koelzer](https://forum.inductiveautomation.com/u/d.koelzer)\
**Post date:** [August 18, 2017, 2:38pm UTC](https://forum.inductiveautomation.com/t/why-cant-asynchronous-threading-be-used-with-components/15103/5 "2017-08-18T14:38:13Z")

</div>

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.
