# Need help understanding system.tag.writeAllSynchronous()

**URL:** <https://forum.inductiveautomation.com/t/need-help-understanding-system-tag-writeallsynchronous/24316>\
**Category:** Ignition\
**Created:** [April 23, 2019, 9:11am UTC](https://forum.inductiveautomation.com/t/need-help-understanding-system-tag-writeallsynchronous/24316 "2019-04-23T09:11:22Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![Esn](https://avatars.discourse-cdn.com/v4/letter/e/91b2a8/32.png) [@Esn](https://forum.inductiveautomation.com/u/Esn)\
**Post date:** [June 24, 2019, 11:28am UTC](https://forum.inductiveautomation.com/t/need-help-understanding-system-tag-writeallsynchronous/24316/21 "2019-06-24T11:28:45Z")

</div>

@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

---

<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:** [June 24, 2019, 12:25pm UTC](https://forum.inductiveautomation.com/t/need-help-understanding-system-tag-writeallsynchronous/24316/22 "2019-06-24T12:25:38Z")

</div>

> [@Esn](#):
>
> I’m not using the event trigger.

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

> [@Esn](#):
>
> How is this an optimization?

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.

[Previous page](https://forum.inductiveautomation.com/t/need-help-understanding-system-tag-writeallsynchronous/24316.md?page=1)
