# Create a background script

**URL:** <https://forum.inductiveautomation.com/t/create-a-background-script/38400>\
**Category:** Ignition\
**Created:** [September 4, 2020, 1:52pm UTC](https://forum.inductiveautomation.com/t/create-a-background-script/38400 "2020-09-04T13:52:42Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [September 4, 2020, 3:01pm UTC](https://forum.inductiveautomation.com/t/create-a-background-script/38400/3 "2020-09-04T15:01:21Z")

</div>

Start here:

> [@Best place to run system.serial.readBytes() in gateway scope for unsolicited data](http://forum.inductiveautomation.com/t/best-place-to-run-system-serial-readbytes-in-gateway-scope-for-unsolicited-data/37248):
>
> Hi As system.serial.readBytes() block script until its timeout pass, what is best place and method to call this functions without causing gateway CPU usage increasing. I’d like a mechanism like interrupt when I receive a char in serial line and then I start to capture my packet. As my device send data unsolicited putting it in a gateway timer may cause I lost packet.

Especially take note of the memory leak opportunities and persistent dictionary solutions.

---

_[View the full topic](https://forum.inductiveautomation.com/t/create-a-background-script/38400)._
