Hi there,
you can do something like this:
- Code: Select all
uses madExcept;
procedure SilenceThreadExceptions(const exceptIntf: IMEException; var handled: boolean);
begin
if exceptIntf.CrashedThreadId <> MainThreadId then
begin
// secondary thread
exceptIntf.GeneralShowSetting := ssNothing;
exceptIntf.AutoContinue := true;
end;
end;
initialization
RegisterExceptionHandler(SilenceThreadExceptions, stDontSync, epQuickFiltering);
end.
This should behave as if the user pressed the "continue application" in the exception box for thread exceptions. Hope that's what you were looking for? The crashed thread will then usually just die, but the application itself should continue to run.
Of course, generally it's a question worth asking if it's a good idea to let your application continue running if there was a crash in a secondary thread. E.g. if the secondary thread has opened some files or entered some critical sections, and then crashes without releasing all that, your application might not be in a safe state to continue running. So maybe you want to use "exceptIntf.AutoRestart := true" instead of "AutoContinue := true"? But I'll leave that decision up to you. If you prefer letting your application continue, then please double check all your threading code and make sure you add "try..finally..end" blocks everywhere to properly release all resources and lock mechanisms in case of an exception.