473,395 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Unhandled exception catching on secondary threads.

I wish to make sure all unhandled exceptions (UE) are handled by a central
handler.
For primary thread UEs, this may be done by

string exceptionText;

AppDomain.CurrentDomain.UnhandledException +=
delegate(object sender, UnhandledExceptionEventArgs e)
{
exceptionText = e.ExceptionObject.ToString();
};

However, this does not work for UEs thrown from a secondary thread like the
timer object (not the forms control).

In this case, the secondary thread is not known until the timer event fires.

Any ideas please?
--
Mike Binks
Progressive Gaming Corp.
Apr 3 '06 #1
3 7286
=?Utf-8?B?TWlrZSBCaW5rcw==?= <Mi*******@discussions.microsoft.com> wrote
in news:7E**********************************@microsof t.com:
I wish to make sure all unhandled exceptions (UE) are handled by a
central handler.


While I'm not sure this deals with your question directly, there is one
thing you need to keep in mind when using AppDomain.UnhandledException.

AppDomain.UnhandledException is NOT a "handler" for the exception - it is
just something that the framework uses to notify you that an exception has
occurred.

I dealt with a similar issue recently as I was developing some code for
handling plugins. The details depend on which version of .NET you are
running. If I remember correctly, the following applies:

In .NET 1.1, exceptions thrown on other threads die away without causing
the application to die.

In .NET 2.0, exceptions thrown on other threads will cause the application
to die.

See the following: (watch the URL wrap)

http://lab.msdn.microsoft.com/Produc...Feedback.aspx?
feedbackId=FDBK21092

A quote from the above URL: "As it turns out, the documentation of
UnhandledException is incorrect. (It's always been incorrect; I've filed a
bug to get it fixed.) The UnhandledException event handler is just a
notification that an exception has gone unhandled. Registering an event
handler does not actually handle the exception; it just handles the event."

-mdb

Apr 3 '06 #2
Hi,

Take a look at Application.ThreadException
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Mike Binks" <Mi*******@discussions.microsoft.com> wrote in message
news:7E**********************************@microsof t.com...
I wish to make sure all unhandled exceptions (UE) are handled by a central
handler.
For primary thread UEs, this may be done by

string exceptionText;

AppDomain.CurrentDomain.UnhandledException +=
delegate(object sender, UnhandledExceptionEventArgs e)
{
exceptionText = e.ExceptionObject.ToString();
};

However, this does not work for UEs thrown from a secondary thread like
the
timer object (not the forms control).

In this case, the secondary thread is not known until the timer event
fires.

Any ideas please?
--
Mike Binks
Progressive Gaming Corp.

Apr 3 '06 #3
Mike,
I recently put a lot of this information together in one place, so this
article

http://www.eggheadcafe.com/articles/20051205.asp

may be helpful. As Michael pointed out, AppDomain.UnhandledException
is NOT an "exception handler".
Cheers,
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Mike Binks" wrote:
I wish to make sure all unhandled exceptions (UE) are handled by a central
handler.
For primary thread UEs, this may be done by

string exceptionText;

AppDomain.CurrentDomain.UnhandledException +=
delegate(object sender, UnhandledExceptionEventArgs e)
{
exceptionText = e.ExceptionObject.ToString();
};

However, this does not work for UEs thrown from a secondary thread like the
timer object (not the forms control).

In this case, the secondary thread is not known until the timer event fires.

Any ideas please?
--
Mike Binks
Progressive Gaming Corp.

Apr 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael Zhang | last post by:
My project uses Python-2.3.4 + Tkinter + PIL-1.1.4 to retrieve images from server and display those images. I created a thread (also a separate toplevel window) for displaying images and another...
2
by: Shravan | last post by:
Hi, Does anybody know how to catch unhandled exceptions in an application. I have tried using AppDomain.UnhandledException Event Application.ThreadException Event but they were not catching...
4
by: Anders Borum | last post by:
Hello! I am working on improving my threading skills and came across a question. When working with the ReaderWriterLock class, I am getting an unhandled exception if I acquire a WriterLock with...
5
by: Lucvdv | last post by:
Can someone explain why this code pops up a messagebox saying the ThreadAbortException wasn't handled? The first exception is reported only in the debug pane, as expected. The second (caused by...
0
by: shaneseaton | last post by:
Hi All, I am subscribed to the AppDomain.CurrentDomain.AssemblyLoad event, which fires whenever a new assembly is loaded. Our application loads an assembly, then through this event, checks to...
3
by: Andreas van de Sand | last post by:
Hi everyone, I've got an application which uses a custom exception handler and to avoid unhandled exceptions I've got a try{}catch (Exception){} block around the main Application.Run(...). ...
0
by: Mike S | last post by:
I'm still looking into this problem, but to summarize: I wrote a very simple Windows Service in VB.NET, as part of a larger application. I created a deployment project for the application the...
8
by: amyl | last post by:
I have an application whose main function is encapsulated in encased in a try/catch block catching Exception. My application has crashed on several occasions with a CLR exception. CLR exception...
1
by: aine_canby | last post by:
Hi, This is my Program class in my Application - static class Program { /// <summary> /// The main entry point for the application. /// </summary>
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.