# Questions about system.util.invokeAsynchronous

**URL:** <https://forum.inductiveautomation.com/t/questions-about-system-util-invokeasynchronous/23366>\
**Category:** Ignition\
**Created:** [March 14, 2019, 9:00pm UTC](https://forum.inductiveautomation.com/t/questions-about-system-util-invokeasynchronous/23366 "2019-03-14T21:00:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cbanzet](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cbanzet/32/6207_2.png) [@cbanzet](https://forum.inductiveautomation.com/u/cbanzet)\
**Post date:** [March 14, 2019, 9:00pm UTC](https://forum.inductiveautomation.com/t/questions-about-system-util-invokeasynchronous/23366/1 "2019-03-14T21:00:19Z")

</div>

I’ve been trying to use system.util.invokeAsynchronous without success. I am suspicious that it is because I am using Sepasoft’s Instrument Interface module to read data from a device over a serial port.

The way to get control of a serial port using the Instrument Interface module is put a “Serial Controller” object onto an Ignition screen. This object is only visible in the designer. It would serve no purpose in a client.

You use the object’s properties and methods to work with a serial port.

What I am doing is reading a large amount of data from the serial port, massaging it and then inserting it into a database. I don’t want the user to have to wait while this is going on - he has plenty that he could be doing during that time. I would like to define all of that as a function and call it with system.util.invokeAsynchronous.

I know that you should not interact with the GUI in the asynchronous thread. Since this object is invisible on the screen and the user can’t interact with it, I wonder if this is considered to be “part of the GUI”. If so, I’m sure that is my problem.

Also, is using Python’s “print” command considered to be an interaction with the GUI? I have sprinkled a few of them throughout the code that I’m trying to run asynchronously to troubleshoot this issue.

---

<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:** [March 14, 2019, 9:38pm UTC](https://forum.inductiveautomation.com/t/questions-about-system-util-invokeasynchronous/23366/2 "2019-03-14T21:38:34Z")

</div>

> [@cbanzet](#):
>
> What I am doing is reading a large amount of data from the serial port, massaging it and then inserting it into a database.

Yeah, you want to run a dedicated thread. This might help:

> [@How to listen serial data without interruption](http://forum.inductiveautomation.com/t/how-to-listen-serial-data-without-interruption/15709/2):
>
> This is actually a rather challenging task, requiring a background thread constantly listening to the serial port. You might find inspiration in this example: [clientserial.py](https://www.automation-pros.com/ignition/clientserial.py).

> [@cbanzet](#):
>
> Also, is using Python’s “print” command considered to an interaction with the GUI?

Technically, yes. But you can get away with it. The down side is it is prone to disappear into the bitbucket on the floor when used in the background. You should use system.util.getLogger() in the background, and everywhere in a gateway scope.

---

<div class="post-metadata">

**Author:** ![cbanzet](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cbanzet/32/6207_2.png) [@cbanzet](https://forum.inductiveautomation.com/u/cbanzet)\
**Post date:** [March 15, 2019, 12:33am UTC](https://forum.inductiveautomation.com/t/questions-about-system-util-invokeasynchronous/23366/3 "2019-03-15T00:33:08Z")

</div>

Thank you so much Phil. I hope that one day I will be able read and understand everything in clientserial.py, but at age 53 I’m not sure I have the life expectancy to do so. 😃

---

<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:** [March 15, 2019, 12:45am UTC](https://forum.inductiveautomation.com/t/questions-about-system-util-invokeasynchronous/23366/4 "2019-03-15T00:45:44Z")

</div>

Heh. I guess it needs more comments. (-:

FWIW, I turn 52 next month…
