Thread.CreateTimer - Is it possible to stop a created thread
Thanks
Thread.CreateTimer - Is it possible to stop a created thread
Thanks
Global value, like a boolean, that the tread checks for, and then exit if true would do it
Here’s what I’ve done to monitor a thread status.
github.com/Twoure/KissNetwork.bundle/blob/master/Contents/Services/Shared%20Code/kissheaders.pys#L207…L229
So when my channel starts after it’s updated or on a fresh install, then I spawn this thread as so: github.com/Twoure/KissNetwork.bundle/blob/master/Contents/Code/__init__.py#L27
Then in the main menu function I’m monitoring the boolean output github.com/Twoure/KissNetwork.bundle/blob/master/Contents/Code/__init__.py#L141
This allows me to log and monitor the threads progress, so when a user exits the channel and comes back, the old thread will be checked for completion or errors. Only if the thread finished successfully will the code continue.
I assume you could do something similar, but add another boolean variable to check against so you can stop/kill the thread.
Edit: forgot to mention, I’m importing the threading lib because the ThreadKit is not available from the shared code directory. So when I call Event() sub with Thread.Event() and also Thread().start() with Thread.Create() as the ThreadKit will create and start the thread immediately.
@dane22 said:
Global value, like a boolean, that the tread checks for, and then exit if true would do it
Thanks
@Twoure said:
Here’s what I’ve done to monitor a thread status.
github.com/Twoure/KissNetwork.bundle/blob/master/Contents/Services/Shared%20Code/kissheaders.pys#L207…L229So when my channel starts after it’s updated or on a fresh install, then I spawn this thread as so: github.com/Twoure/KissNetwork.bundle/blob/master/Contents/Code/__init__.py#L27
Then in the main menu function I’m monitoring the boolean output github.com/Twoure/KissNetwork.bundle/blob/master/Contents/Code/__init__.py#L141
This allows me to log and monitor the threads progress, so when a user exits the channel and comes back, the old thread will be checked for completion or errors. Only if the thread finished successfully will the code continue.
I assume you could do something similar, but add another boolean variable to check against so you can stop/kill the thread.
Edit: forgot to mention, I’m importing the threading lib because the ThreadKit is to available from the shared code directory. so when I call
Event()sub withThread.Event()andThread().start()withThread.Create()as the ThreadKit will create and start the thread immediately.
Thanks