473,748 Members | 2,361 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Curre ntDomain.Unhand ledException +=
delegate(object sender, UnhandledExcept ionEventArgs e)
{
exceptionText = e.ExceptionObje ct.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 7306
=?Utf-8?B?TWlrZSBCaW5 rcw==?= <Mi*******@disc ussions.microso ft.com> wrote
in news:7E******** *************** ***********@mic rosoft.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.Unhan dledException.

AppDomain.Unhan dledException 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=FDBK 21092

A quote from the above URL: "As it turns out, the documentation of
UnhandledExcept ion is incorrect. (It's always been incorrect; I've filed a
bug to get it fixed.) The UnhandledExcept ion 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.Thr eadException
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Mike Binks" <Mi*******@disc ussions.microso ft.com> wrote in message
news:7E******** *************** ***********@mic rosoft.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.Curre ntDomain.Unhand ledException +=
delegate(object sender, UnhandledExcept ionEventArgs e)
{
exceptionText = e.ExceptionObje ct.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.Unhan dledException
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.Curre ntDomain.Unhand ledException +=
delegate(object sender, UnhandledExcept ionEventArgs e)
{
exceptionText = e.ExceptionObje ct.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
4399
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 thread for recording the frame rates (using a progress bar for visulization). The whole application worked very well once it received image data from the socket. The problem is when I tried to close that display window (click on the standard...
2
1847
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 unhandled exceptions always. There are not working in some cases.
4
5512
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 a timeout less than the time required to process the code section it protects. The code listed below is just a small application I wrote to check the behavious of the different threading / synchronization techniques. Basically the application...
5
5746
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 thread.Abort()) is reported twice: once in the debug window, and once through the message box. Is it because the thread was sleeping when the exception occurred?
0
967
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 see that the assembly conforms to a set of rules. If the assembly does not conform, then I throw an exception that (for now) should cause the whole application to come to a crashing halt, as it is unhandled by any of my code. However the problem...
3
1950
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(...). Works all good on my machine, whenever something unexpected happens the exception get caught, logged and it shows a nicer message. Unfortunately for some reason, this only works on my machine! If i deploy my project to some other computer I get the...
0
1462
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 resulting MSI explicitly installs the service. I've ran the installer on 4 machines at our office (2 are running Windows 2000 Pro, 1 is running XP Pro, and the other is running Windows 98). On each of these machines, the installation goes without a...
8
17598
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 - code e0434f4d (!!! second chance !!!) So far I have been unable to create a test case that reproduces the crash. My application makes extensive use of asynchronous programming using waithandles.
1
1851
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
8823
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9312
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8237
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.