TMadExceptionHandler not always called.

delphi package - automated exception handling
Post Reply
tniemann
Posts: 4
Joined: Thu Mar 02, 2006 10:40 pm

TMadExceptionHandler not always called.

Post by tniemann »

Madshi,

I have the TMadExceptionHandler on the MainForm of my application however it is not always called before MadExcept handles the error.

You can see a sample of this here: http://support.zierniemann.com/default.asp?4153_GWAA

I need VCL support because I prehandle a lot of the errors.

Any ideas?

Thanks,
Tony
madshi
Site Admin
Posts: 10766
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Hmmmm... Can you create a demo project which reproduces the problem?

Generally when using TMadExceptionHandler madExcept tries to call your handler in the context of the main thread. If that fails, madExcept does NOT call your handler.

If you want to make absolutely sure that you get called for every exception, you should not use TMadExceptionHandler, but call RegisterExceptionHandler instead. You can use "stTrySyncCallAlways". This will try to behave similiar to the TMadExceptionHandler. But if calling of your exception handler inside of the main thread context doesn't work, your handler is called nevertheless (in the context of a secondary thread). Of course in the latter case you have to be careful what you're doing. You can check whether you're running in the main thread by asking "if GetCurrentThreadID = MainThreadID".
Post Reply