PC Review


Reply
Thread Tools Rate Thread

Can UnhandledExceptionEventHandler cancel the CLR exception handli

 
 
=?Utf-8?B?dGNodQ==?=
Guest
Posts: n/a
 
      31st Aug 2006
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?=
Guest
Posts: n/a
 
      8th Sep 2006
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

 
Reply With Quote
 
David Levine
Guest
Posts: n/a
 
      8th Sep 2006

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" <(E-Mail Removed)> wrote in
message news:84A9B3E3-EE0F-42CA-AE69-(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem getting UnhandledExceptionEventHandler to work in service application Manfred Braun Microsoft C# .NET 1 27th Jul 2010 04:25 PM
SQL Server Stored Procedure Try Catch and ADO.Net exception handli =?Utf-8?B?UGhpbCBTaGFycA==?= Microsoft ADO .NET 8 18th Jun 2007 04:23 PM
UnhandledExceptionEventHandler Glen Microsoft C# .NET 0 13th Dec 2004 10:06 PM
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Timothy Parez Microsoft Dot NET Framework Forms 1 17th Mar 2004 12:00 AM
OutOfMemoryException and UnhandledExceptionEventHandler Ryan Seghers Microsoft Dot NET 4 12th Feb 2004 11:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:12 AM.