Check if main thread froze from a thread?

delphi package - automated exception handling

Check if main thread froze from a thread?

Postby cpstevenc » Thu Mar 29, 2018 8:53 pm

Using Tokyo Update 2.

First like to say, been using madExcept for a few years now, and it has been a life saver in many situations. Helped find issues in very old apps that existed before I started working here years ago.

Anyways, I'd like to have ability to have background threads to check if the UI froze up.... if this the case, then would be nice to just have the thread quit out and no try to bother updating the UI.

Did some googling and what not, but didn't see any sure fire way of doing this. So figured I'd ask.

Closest I got maybe to this was using RegisterException but this appeared to be a case where you call this during your try/except areas.
cpstevenc
 
Posts: 2
Joined: Thu May 29, 2014 2:39 am

Re: Check if main thread froze from a thread?

Postby cpstevenc » Fri Mar 30, 2018 6:16 am

I think I found my answer @ viewtopic.php?t=4184
cpstevenc
 
Posts: 2
Joined: Thu May 29, 2014 2:39 am

Re: Check if main thread froze from a thread?

Postby madshi » Tue Apr 03, 2018 9:49 am

The actual freeze checking is done automatically if you activate the option "check for frozen main thread" here:

http://help.madshi.net/madExceptSettings1.htm

If you want custom behaviour in case a freeze is detected, you can use RegisterExceptionHandler(), as mentioned in the other thread you already found.

Please note that if your main thread does something time consuming which doesn't handle messages (e.g. printing, I don't know), if you set the freeze check timeout too low, madExcept might incorrectly think that your main thread is no longer responding, while it actually is just busy. Of course it's probably bad design, if you do time consuming stuff in the main thread without handling messages. But hey, many applications do stuff like that (sadly). So just make sure you pick a proper timeout value which is not too short. Also, if you have loops which do time consuming stuff without handling messages, you can call "ImNotFrozen" within those loops to signal to madExcept that your main thread is still alive and kicking. That's not necessary if your application is properly designed, of course (meaning: no time consuming stuff without message handling in the main thread).
madshi
Site Admin
 
Posts: 9808
Joined: Sun Mar 21, 2004 5:25 pm


Return to madExcept

Who is online

Users browsing this forum: No registered users and 3 guests

cron