Board index » delphi » Thread to monitor the primary thread?

Thread to monitor the primary thread?

Is it possible to create a thread which can monitor the primary thread, and
kill it if it stops responding for some period of time?  We have a
communications app which gets hung while talking to a remote machine, and
it will not respond to ANY windows messages once it is hung.  We are trying
to see if we can write a thread which will simply monitor the activity of
the primary thread, and kill the app if it detects that no progress has
been made for a specified period of time.  Is this logical?  Possible?
Thanks...
-Howard Moon
 

Re:Thread to monitor the primary thread?


Quote
> Is it possible to create a thread which can monitor the primary thread, and
> kill it if it stops responding for some period of time?  We have a
> communications app which gets hung while talking to a remote machine, and
> it will not respond to ANY windows messages once it is hung.  We are trying
> to see if we can write a thread which will simply monitor the activity of
> the primary thread, and kill the app if it detects that no progress has
> been made for a specified period of time.  Is this logical?  Possible?

Howard,

take a look at SendMessageTimeout in win32.hlp. The watchdog thread could use
that to regularly send a user message to the main window and pull the plug
via TerminateProcess if it times out. Of course it would be better to fix the
source of the hangs <g>.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitely requested!

Other Threads