Global error handler

  • Thread starter Thread starter UJ
  • Start date Start date
U

UJ

Is there a way to do a global error handler much the way you can in asp.net
? Essentially I want to set up a routine that if there is any unhandled
exception it will call that routine so I can process it. I do quite a bit
with timers so if I had to put code in in each place where an error could
happen, it would be difficult.

TIA - Jeff
 
UJ said:
Is there a way to do a global error handler much the way you can in asp.net
? Essentially I want to set up a routine that if there is any unhandled
exception it will call that routine so I can process it. I do quite a bit
with timers so if I had to put code in in each place where an error could
happen, it would be difficult.

Have a look at these two events:

AppDomain.CurrentDomain.UnhandledException
Application.ThreadException

hth,
Max
 
Maybe I didn't make myself clear. I want this for a windows program. I want
the equivalent of the Application_Error event from the web side.

I essentially want a way to trap any unhandled error someplace so the
message doesn't display to the user.

TIA - Jeff.
 
You did make yourself clear, and Markus give you the correct answer.
Take a look at those two events. As well, if you search for the event
names on MSDN you should find at least one article on global event
handling in .NET.
 
Bruce Wood said:
You did make yourself clear, and Markus give you the correct answer.
Take a look at those two events. As well, if you search for the event
names on MSDN you should find at least one article on global event
handling in .NET.

Although, IIRC, these don't catch unhandled exceptions from threadpool
threads. I may be wrong on that.

-- Alan
 
Alan said:
Although, IIRC, these don't catch unhandled exceptions from threadpool
threads. I may be wrong on that.

No, you are right. These two events catch only events from the UI
thread, not from background threads.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top