# How to shut down the asynchronous thread in script console

**URL:** <https://forum.inductiveautomation.com/t/how-to-shut-down-the-asynchronous-thread-in-script-console/81520>\
**Category:** Ignition\
**Created:** [November 6, 2023, 3:03am UTC](https://forum.inductiveautomation.com/t/how-to-shut-down-the-asynchronous-thread-in-script-console/81520 "2023-11-06T03:03:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenny\_Chen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kenny_chen/32/76633_2.png) [@Kenny\_Chen](https://forum.inductiveautomation.com/u/Kenny_Chen)\
**Post date:** [November 6, 2023, 3:03am UTC](https://forum.inductiveautomation.com/t/how-to-shut-down-the-asynchronous-thread-in-script-console/81520/1 "2023-11-06T03:03:01Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![hunterdg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hunterdg/32/67774_2.png) [@hunterdg](https://forum.inductiveautomation.com/u/hunterdg)\
**Post date:** [November 6, 2023, 3:35am UTC](https://forum.inductiveautomation.com/t/how-to-shut-down-the-asynchronous-thread-in-script-console/81520/2 "2023-11-06T03:35:26Z")

</div>

Gateway Webpage \> Status \> Diagnostics \> Running Scripts

---

<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:** [November 6, 2023, 12:12pm UTC](https://forum.inductiveautomation.com/t/how-to-shut-down-the-asynchronous-thread-in-script-console/81520/3 "2023-11-06T12:12:57Z")

</div>

> [@hunterdg](#):
>
> Gateway

Gateway is totally not applicable to the script console.

> [@Kenny\_Chen](#):
>
> the asynchronous thread

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.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [November 6, 2023, 12:26pm UTC](https://forum.inductiveautomation.com/t/how-to-shut-down-the-asynchronous-thread-in-script-console/81520/4 "2023-11-06T12:26:00Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/b/1b06d45bd7ac0aa1fef0cc6d10f466fbe47ce0b5.png)

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.

---

<div class="post-metadata">

**Author:** ![hunterdg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hunterdg/32/67774_2.png) [@hunterdg](https://forum.inductiveautomation.com/u/hunterdg)\
**Post date:** [November 10, 2023, 2:48pm UTC](https://forum.inductiveautomation.com/t/how-to-shut-down-the-asynchronous-thread-in-script-console/81520/5 "2023-11-10T14:48:59Z")

</div>

> [@pturmel](#):
>
> Gateway is totally not applicable to the script console

oops, replied too quickly, but it's useful for runaway perspective/gateway scripts.

> [@pturmel](#):
>
> 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.

Learn something new every day!

---

<div class="post-metadata">

**Author:** ![Kenny\_Chen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kenny_chen/32/76633_2.png) [@Kenny\_Chen](https://forum.inductiveautomation.com/u/Kenny_Chen)\
**Post date:** [December 1, 2023, 1:27am UTC](https://forum.inductiveautomation.com/t/how-to-shut-down-the-asynchronous-thread-in-script-console/81520/6 "2023-12-01T01:27:53Z")

</div>

thanks a lot !! pretty coooooool

---

<div class="post-metadata">

**Author:** ![jorge.galvez](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jorge.galvez](https://forum.inductiveautomation.com/u/jorge.galvez)\
**Post date:** [December 4, 2023, 8:55pm UTC](https://forum.inductiveautomation.com/t/how-to-shut-down-the-asynchronous-thread-in-script-console/81520/7 "2023-12-04T20:55:18Z")

</div>

Hi all,  
Is it possible to programmatically check if the asyncronous thread called by `system.util.invokeAsynchronous()` is still running in order to avoid upcoming invokes?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [December 4, 2023, 9:58pm UTC](https://forum.inductiveautomation.com/t/how-to-shut-down-the-asynchronous-thread-in-script-console/81520/8 "2023-12-04T21:58:39Z")

</div>

There is some good info on that here  
[Managing multiple asynchronous threads - Ignition - Inductive Automation Forum](https://forum.inductiveautomation.com/t/managing-multiple-asynchronous-threads/37185)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 4, 2023, 10:04pm UTC](https://forum.inductiveautomation.com/t/how-to-shut-down-the-asynchronous-thread-in-script-console/81520/9 "2023-12-04T22:04:48Z")

</div>

> [@jorge.galvez](#):
>
> Is it possible to programmatically check if the asyncronous thread called by `system.util.invokeAsynchronous()` is still running in order to avoid upcoming invokes?

`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 [`Executors`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/Executors.html).
