# "Tag Change" gateway event script vs "Value Changed" tag value event

**URL:** <https://forum.inductiveautomation.com/t/tag-change-gateway-event-script-vs-value-changed-tag-value-event/105407>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [April 22, 2025, 4:00pm UTC](https://forum.inductiveautomation.com/t/tag-change-gateway-event-script-vs-value-changed-tag-value-event/105407 "2025-04-22T16:00:58Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 22, 2025, 6:01pm UTC](https://forum.inductiveautomation.com/t/tag-change-gateway-event-script-vs-value-changed-tag-value-event/105407/2 "2025-04-22T18:01:50Z")

</div>

> [@samhallak](#):
>
> Is this concern real?

Yes, it is very real.

Not only is the valueChange script queue bounded to 5 per tag, but there is also a bounded thread pool, such that only 3 scripts can run at one time. This adds to the possibility of queue sizes building up and eventually discarding events that are pushed out of the queue.

valueChange events should never run long running tasks, and should not run longer latency tasks such as interfacing with databases.

> [@samhallak](#):
>
> And "queue" implies they would run serially, avoiding risk of deadlocks. Is that correct?

Yes, to an extent, each event in the queue is executed in order prior to the next event being processed, for all tags assigned to that Gateway Tag Change Event. You can split different changes across multiple threads (allowing asynchronous execution) by defining multiple change events. So in this case you will want to author your script to be generic and assign all tags to that event.

For reference:

> [@Script execution time](https://forum.inductiveautomation.com/t/script-execution-time/98211/2):
>
> Each kind of gateway event uses its own thread model, and run independently (parallel) of other event types. Java and Jython are fully multi-threaded, unlike CPython. Some event types offer a single shared thread or a dedicated thread per event definition, selectable. Most event types, like gateway tag change events, simply use a dedicated thread per event definition. (Multiple tags assigned to such an event are processed one at a time, in order.) If you want two threads handling various ta…

I would also recommend that you look into the `initialChange` flag.

---

_[View the full topic](https://forum.inductiveautomation.com/t/tag-change-gateway-event-script-vs-value-changed-tag-value-event/105407)._
