Script vs scan class


If a script in a tag’s value change event take a long time to execute, will it stop the refresh of all the tags from the same scan class?

Possibly. Depends on what else is going on, I believe. Use a gateway tag change event script instead of a tag event–value change. The former allows you to specify a dedicated thread.

I understand. But we extensibly use UDT and some tags in the UDT contain value change script. The goal is to not have to create individual script.

Does system.util.invokeAsynchronous works in value change script? I could use that to call function that can be long to execute.

You don’t. You simply add the tag to the list for the one tag change event. If you really want to minimize code duplication, tag change events are far superior to tag events.

Should work. But you loose the overlapping event protection that the tag change event script automatically provides.

I did a small test.

I create 3 tags using the same scan class.:

One of the tags is an OPC tag. I read a flashing bit in a plc. The scrip tag is a memory tag. When it vlaue change, a script write its value in the written tag after some delay with a while loop (worst case). Here is the code:

counter = 0
otherEvent = 0
while 1:
    counter += 1
    if  counter >= 100000000:

Then, when I toogle the ScriptTag, the OPCtag continue to flash. So it seems the script in the ScriptTag does not affect the scan class.

Where? (The former allows you to specify a dedicated thread)

As far as I can see, this is only possible for Gateway Timer Scripts, not Gateway Tag Change Scripts.


Huh. Missed that. Sorry @zxcslo. :frowning_face:

If you really need a dedicated thread, I would create my own executor in a script module, with a function to submit a custom runnable with your event object. See for an example.