# Loading symbol while waiting for script to complete

**URL:** <https://forum.inductiveautomation.com/t/loading-symbol-while-waiting-for-script-to-complete/18649>\
**Category:** Ignition\
**Tags:** ignition79, database, scripting\
**Created:** [June 27, 2018, 6:54pm UTC](https://forum.inductiveautomation.com/t/loading-symbol-while-waiting-for-script-to-complete/18649 "2018-06-27T18:54:22Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 27, 2018, 7:43pm UTC](https://forum.inductiveautomation.com/t/loading-symbol-while-waiting-for-script-to-complete/18649/2 "2018-06-27T19:43:29Z")

</div>

All scripting you do in the client runs (by default, and very deliberately) on the main Java Swing thread (also known as the Event Dispatch Thread). Any interaction with the GUI (ie, telling a component property to update, or animating a progress bar) _must_ happen on this thread, or deadlocks can result.

We offer two helper functions to aid in working around this restriction:  
[`system.util.invokeAsynchronous`](https://docs.inductiveautomation.com/display/DOC/system.util.invokeAsynchronous) which allows you to run a defined function on a background thread, and  
[`system.util.invokeLater`](https://docs.inductiveautomation.com/display/DOC/system.util.invokeLater), which allows that background thread to place operations _into the queue_ of the GUI thread to maintain thread-safety. So an extremely reductive example would be something like:

```auto
def setProgressBarState(target=event.source.parent.getComponent('Progress Bar')):
	target.value = target.value + 10

def mySlowFunction():
	# run some slow DB operation
	system.util.invokeLater(setProgressBarState)
	# run another slow DB operation
	system.util.invokeLater(setProgressBarState)
	# run another slow DB operation
	system.util.invokeLater(setProgressBarState)

system.util.invokeAsynchronous(mySlowFunction)

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/loading-symbol-while-waiting-for-script-to-complete/18649)._
