I am a beginner of ignition. Recently i found that when i clicked the ‘interrupt' button in my script console to modify my script, but accidently restarted it quickly before the interruption went into effect (e.g. click the button again accidently), the previous script would keep running and outputing computed result. This influents a lot cuz the scripts output at the same time. Would you please teach me how to shut down the asynchronous thread in script console, thanks a lot!
Gateway Webpage > Status > Diagnostics > Running Scripts
Gateway is totally not applicable to the script console.
If you really had an asynchronous thread (started by
system.util.invokeAsynchronous()), then you cannot interrupt it. The script console's interrupt can only stop a foreground operation right there in the console.
You cannot do this from the script console directly afaik but in the newer versions at least you should be able to from this tab in the Diagnostics. Click refresh to see what scripts are running then you can select one and click the trash can.
It will then throw a
ScriptCanceledError: Script canceled. This is also available in the actual vision clients as well as designer. Works for scripts you triggered with a button press or invoked directly in the script console via invokeAsynchronously.
oops, replied too quickly, but it's useful for runaway perspective/gateway scripts.
Learn something new every day!
thanks a lot !! pretty coooooool
Is it possible to programmatically check if the asyncronous thread called by
system.util.invokeAsynchronous() is still running in order to avoid upcoming invokes?
There is some good info on that here
Managing multiple asynchronous threads - Ignition - Inductive Automation Forum
system.util.invokeAsynchronous should really only be used for true fire-and-forget events. If you have a need for more capability, you should be implementing your own operations against a lower level Java class, such as by taking advantage of a factory from