In Ignition 8.0.14, when I try to use the “system.util.invokeLater ()” function in a Gateway Event Script (tag change), this error is logged in the logs:
This is the code:
Logger_Script = system.util.getLogger("probar")
invokeLater is only available when code is executing in client/designer scope. If you understand what it’s actually doing - running some piece of code later on the Swing Event Dispatch Thread, then it should be obvious why.
Perhaps you are misusing/abusing
I think your answer is very hasty. According to the documentation: “The Threading Library has a Timer function that works in a very similar fashion to invokeLater.”
“Timer” does work in Gateway Events Script, so I thought “invokeLater” would work too.
When a tag changes, I need to execute a function after a few seconds, that’s why “invokeLater” seemed correct to me.
I understand that I have to use “Timer”.
@pturmel has a
later.py implementation here on the forums that uses an (internal) class to allow for the ‘delayed execution’ functionality of
invokeLater to work on the gateway.
Bleh, I wish the training team hadn’t written those docs advocating the use of
invokeLater as a convenient way to introduce a delay. That’s really not what it’s for.
Jython’s Timer seems fine, but it’s conceptually no different than just using
invokeAsync and then sleeping as the first thing you do for the amount of delay you desire. Both end up using a dedicated Thread.