Tech Support > Microsoft Windows > Development Resources > Exception in Thread
Exception in Thread
Posted by wisdom@operamail.com on November 13th, 2006


Is there any way to catch an exception from one thread that occurs in a
different thread? I am working with a library that I did not write,
and I do not have access to the source code. It's causing an exception
in a case that I should be able to easily recover from, if I can find
some way to catch it, and continue excecuting. Any suggestions?

Thanks
IO

Posted by Ulrich Eckhardt on November 13th, 2006


wisdom@operamail.com wrote:
If you have access to the thread entry function, you can easily add a
try-catch clause and then signal the exception somehow, e.g. via the
returnvalue. From the other thread you can then use GetThreadExitCode (or
somesuch) to retrieve that value.

Uli


Posted by wisdom@operamail.com on November 13th, 2006



Ulrich Eckhardt wrote:

Yes, unfortunately, I do not. I simply call a function that is part of
the library and pass it a file name. I believe that it starts a
separate worker thread that opens the file, and parses it. Somewhere
in there, it fails on some files, and throws an exception. If I place
a try..catch block around the function, it doesn't catch the exception,
so that's why I assume that another thread is involved.

Thanks
IO


Posted by Olof Lagerkvist on November 13th, 2006


wisdom@operamail.com wrote:
You can install an Unhandled Exception Filter for the process. Look at
the SetUnhandledExceptionFilter() API.

--
Olof Lagerkvist
ICQ: 724451
Web: http://here.is/olof