Invoke, threads, and exceptions

  • Thread starter Thread starter Chris Soulsby
  • Start date Start date
C

Chris Soulsby

If an exception is raised in a non-main thread then it is not handled.
To get around this I created method that would use the invoke method
on the main form to raise this exception on the main thread. For
example:

this.Invoke(new InvokeDelegate(this.ThreadExceptionHandler),new
object[]{o});

However, this still does not seem to work correctly as I still get an
unhandled exception. It does not fall back to the main() function
where my catch all code is. Can anyone tell me whats going on?

Thanks for any help.

Chris
 
Chris said:
If an exception is raised in a non-main thread then it is not handled.
To get around this I created method that would use the invoke method
on the main form to raise this exception on the main thread.

Why not use:
AppDomain.CurrentDomain.UnhandledException += new
UnhandledExceptionEventHandler(...);


--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp
 
Try this:
-Put all thread code in a big try catch
-On the catch branch raise an user define event or invoke SendMessage API
-After this you can handle the event in the main App (if you send an message
override the WndProc and catch it)

Hope this helps

Dan Cimpoiesu
 
Back
Top