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

Ask for help, how to use AHK_H, etc.
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

How to stop the entire process if a thread is terminated

27 Jan 2019, 09:44

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.
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

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

28 Jan 2019, 13:22

You can check if threads are running using ahkReady, you can set up a timer routine to check periodically.
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

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

28 Jan 2019, 13:45

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
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

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

28 Jan 2019, 15:09

call AhkExported() in the sub-thread to get a handle to main thread

Return to “Ask for Help”

Who is online

Users browsing this forum: No registered users and 20 guests