Killing/Interrupting a Thread started by system.util.invokeAsynchronous

Hello,

system.util.invokeAsynchronous returns the Thread it starts which is great, but I'm missing something in how I might be able to store that Thread object, or reference - so I can stop the Thread later on.

ex: I have a local TCP connection being established from a Vision client to another application on a device. Occasionally that application stops sending data unless a new connection is made (ie: it times out on its end without closing the connection).. I would like to then initiate a new connection... without blocking the HMI, so I've needed to use system.util.invokeAsynchronous - however anytime I start a new connection, it starts in a new thread and there's still that original connection.

If I'm starting a thread based on a property or button event, how can I later on reference that thread?

Thanks!

The real answer here is that the thread should manage it's own lifecycle. You shouldn't kill threads.

2 Likes

That's a really good point and probably the crux of my problem - if there's a problem with the connection and I need to start anew, I can interupt, and note if possible

Thanks for the sanity check