473,395 Members | 2,006 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.

Can UnhandledExceptionEventHandler cancel the CLR exception handli

I found that in VB.Net, My.Application.UnhandledException can cancel the
exception handling by setting the ExitApplication property of
UnhandledExceptionEventArgs parameter to false.
Can the same thing be done in C#?

regards,
tchu
Aug 31 '06 #1
2 2723
The basic method used by the Vb stuff is to wrap the call to Application.Run
(usually found in Main()) in a try catch block. Then in the catch fire the
event you handle with the event args allowing you to choose to close or not.
After raising the event, if the arguments say to exit then it calls
Application.Exit();

There is no automatic way of doing this in C# but it would only take a few
minutes to code up and it could work the same way.
HTH
Ciaran O'Donnell

"tchu" wrote:
I found that in VB.Net, My.Application.UnhandledException can cancel the
exception handling by setting the ExitApplication property of
UnhandledExceptionEventArgs parameter to false.
Can the same thing be done in C#?

regards,
tchu
Sep 8 '06 #2

That would work only in the case where exception occurred on the same thread
that was wrapped. In essence this prevents a CLR UE from occurring as the
exception is caught. If the exception occurs on a different thread then it
will have no effect and a UE will occur.

"Ciaran O''Donnell" <Ci************@discussions.microsoft.comwrote in
message news:84**********************************@microsof t.com...
The basic method used by the Vb stuff is to wrap the call to
Application.Run
(usually found in Main()) in a try catch block. Then in the catch fire the
event you handle with the event args allowing you to choose to close or
not.
After raising the event, if the arguments say to exit then it calls
Application.Exit();

There is no automatic way of doing this in C# but it would only take a few
minutes to code up and it could work the same way.
HTH
Ciaran O'Donnell

"tchu" wrote:
>I found that in VB.Net, My.Application.UnhandledException can cancel the
exception handling by setting the ExitApplication property of
UnhandledExceptionEventArgs parameter to false.
Can the same thing be done in C#?

regards,
tchu

Sep 8 '06 #3

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

Similar topics

10
by: Hautzendorfer | last post by:
Hello, I'm currently working on some printing stuff: I have to print out several .xml files using a stylesheet. Therefor I choose the Internetexplorer PlugIn via SHDocVW. My problem: After...
4
by: Ryan Seghers | last post by:
I've got a program that has no user interface (like a service but not actually a Windows Service yet) in which I'd like to handle OutOfMemoryExceptions. I'd at least like to log the failure before...
0
by: Manfred Braun | last post by:
Hi All, in a windows service application , I add an eventhandler to the Application Domain: public static void Main() { System.ServiceProcess.ServiceBase.Run(new SimpleServiceDemo1());;...
0
by: Glen | last post by:
I've set up the UnhandledExceptionEventHandler delegate in a console application (Main()) to handle any exceptions that bubble up from the stack and are not handled explicitly by other try/catch...
3
by: Stijn Vanroye | last post by:
Hi List, I'm running a query on a not-so-small db. Mostly this query runs fast enough, but every once in a while the query takes a long time to complete in wich case the users start banging away...
0
by: Peter Bromberg [C# MVP] | last post by:
Recently another developer I work with and I were discussing ways to log more information than just the stock event log entry when an app blows up because of an unhandled exception. There were a...
1
by: Michael R | last post by:
I am using a PrintPreviewDialog to show a document. Via the BeginPrint event, I open a PrintDialog to let the user choose what pages (and other settings) to print. However, I can't find a way to...
1
by: David Veeneman | last post by:
Does anyone knmow why an asynchronous worker method would crash if the e.Cancel method is set to true, but not otherwise? I'm working on a demo app with an asynchronous call, using the .NET 2.0...
2
by: Robinson | last post by:
I can start an Asynchronous operation against a data source with SQLCommand.BeginExecuteReader, allowing me to loop, checking for user cancellation before the operation has completed, but how then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.