Page 1 of 1

How to stop the entire process if a thread is terminated

Posted: 27 Jan 2019, 09:44
by kyuuuri
Hello, as title says I would like to know how to kill the entire process if a thread is killed/paused/etc.
There are tools to stop or kill individual threads and I don't want to let my users run the program removing an important thread, so how do I prevent this?
Anything that closes/crashes/stops the process works.

Thank you.

Re: How to stop the entire process if a thread is terminated  Topic is solved

Posted: 28 Jan 2019, 13:22
by HotKeyIt
You can check if threads are running using ahkReady, you can set up a timer routine to check periodically.

Re: How to stop the entire process if a thread is terminated

Posted: 28 Jan 2019, 13:45
by kyuuuri
Nice thank you!.
Last question:
If I have 2 threads, the main one and 1 created from the main one, how can I check if the main thread has been stopped/paused.
I mean something like:

Code: Select all

#persistent
SubThread=
(
#persistent
settimer, CheckMainThread, 100
return

CheckMainThread:
; What to put here since I don't have any Object for the main Thread.
return
)

a := AhkThread(SubThread)
settimer, CheckSubThread, 100
return

CheckSubThread:
if !(a.ahkReady())
	msgbox SubThread Stopped

Re: How to stop the entire process if a thread is terminated

Posted: 28 Jan 2019, 15:09
by swagfag
call AhkExported() in the sub-thread to get a handle to main thread

Re: How to stop the entire process if a thread is terminated

Posted: 28 Jan 2019, 17:32
by kyuuuri
Thank you!