473,480 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Error and close application

Hi
I'm using Visual Studio 2005 with visual basic, developing winforms
applications
I'm adding try catch blocks for error handling and I want to close the
application when I got an error.
Closing the form is not enough because there is a lot of forms open

TIA

Rodrigo Juarez
Feb 16 '07 #1
8 3317
"Rodrigo Juarez" <ti**************@newsgroup.nospamschrieb
Hi
I'm using Visual Studio 2005 with visual basic, developing winforms
applications
I'm adding try catch blocks for error handling and I want to close
the application when I got an error.
Closing the form is not enough because there is a lot of forms open
If you don't have multiple forms: Application.ExitThread
Armin
Feb 16 '07 #2
Thanks for your reply
I have a lot of forms open when I got error
"Armin Zingler" <az*******@freenet.deescribió en el mensaje
news:eN**************@TK2MSFTNGP02.phx.gbl...
"Rodrigo Juarez" <ti**************@newsgroup.nospamschrieb
>Hi
I'm using Visual Studio 2005 with visual basic, developing winforms
applications
I'm adding try catch blocks for error handling and I want to close
the application when I got an error.
Closing the form is not enough because there is a lot of forms open

If you don't have multiple forms: Application.ExitThread
Armin

Feb 16 '07 #3
"Armin Zingler" <az*******@freenet.deschrieb
"Rodrigo Juarez" <ti**************@newsgroup.nospamschrieb
Hi
I'm using Visual Studio 2005 with visual basic, developing
winforms applications
I'm adding try catch blocks for error handling and I want to close
the application when I got an error.
Closing the form is not enough because there is a lot of forms
open

If you don't have multiple forms: Application.ExitThread

Correction:
If you don't have multiple Threads...
Armin
Feb 16 '07 #4

"Rodrigo Juarez" <ti**************@newsgroup.nospamwrote in message
news:e5**************@TK2MSFTNGP06.phx.gbl...
Hi
I'm using Visual Studio 2005 with visual basic, developing winforms
applications
I'm adding try catch blocks for error handling and I want to close the
application when I got an error.
Closing the form is not enough because there is a lot of forms open

TIA

Rodrigo Juarez
So whenever you get an error, you want to close all of the forms and exit
the application?

Is that what you're trying to achieve?

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
Feb 16 '07 #5
Yes, this is what I want

Thanks!

Rodrigo Juarez

"RobinS" <Ro****@NoSpam.yah.noneescribió en el mensaje
news:ae******************************@comcast.com. ..
>
"Rodrigo Juarez" <ti**************@newsgroup.nospamwrote in message
news:e5**************@TK2MSFTNGP06.phx.gbl...
>Hi
I'm using Visual Studio 2005 with visual basic, developing winforms
applications
I'm adding try catch blocks for error handling and I want to close the
application when I got an error.
Closing the form is not enough because there is a lot of forms open

TIA

Rodrigo Juarez

So whenever you get an error, you want to close all of the forms and exit
the application?

Is that what you're trying to achieve?

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.


Feb 16 '07 #6
If you are catching the exceptions in your code, you can choose whether to
throw them up another level or handle them. Generally, it's best to handle
them "in place". Why would you want to shut everything down just because
there is an error?

At any rate, if you want to do this, you have to figure out where you want
to close your forms. If you do it in a Form_Closing event, you'll need to
close all *other* forms. If you try to close a form in its own Form_Closing
event, it will probably loop infinitely or something.

For Each myForm As Form In My.Application.OpenForms
If myForm.name <"whateverformiscallingthis" Then
myForm.Close()
End If
Next

If you are letting the exceptions bubble up to the top and handling them in
the Application UnhandledException event that I told you about in the other
thread, you can just close all the forms there.

For Each myForm As Form In My.Application.OpenForms
myForm.Close()
Next

IMHO, this is not a best practice. <:-O

Robin S.
-----------------------------------------
"Rodrigo Juarez" <ti**************@newsgroup.nospamwrote in message
news:e9*************@TK2MSFTNGP05.phx.gbl...
Yes, this is what I want

Thanks!

Rodrigo Juarez

"RobinS" <Ro****@NoSpam.yah.noneescribió en el mensaje
news:ae******************************@comcast.com. ..
>>
"Rodrigo Juarez" <ti**************@newsgroup.nospamwrote in message
news:e5**************@TK2MSFTNGP06.phx.gbl...
>>Hi
I'm using Visual Studio 2005 with visual basic, developing winforms
applications
I'm adding try catch blocks for error handling and I want to close the
application when I got an error.
Closing the form is not enough because there is a lot of forms open

TIA

Rodrigo Juarez

So whenever you get an error, you want to close all of the forms and
exit the application?

Is that what you're trying to achieve?

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.



Feb 17 '07 #7
Hi Robin ,

Thank you for sharing your idea with Rodrigo!

I agree with most of your comment. Based on my experience, there are 2
types of exceptions/errors in application, one is expected and one is
unexpected. Expected error(such as file not found etc..) is known to the
developers, so it would be safe to gracefully recover from this error and
let the application continue to run without closing. In the unexpected
error scenario, I think it may be better to close the application, since
developers know nothing of this error, it may be hardware error, memory
insufficiency or even memory corruption, so it may be unsafe to run from
this situation. The recommended solution in this scenario may be closing
the entire application. Also, this is default behavior of Win32 unhandled
exception filter in NTDLL.

Additionally, Rodrigo, you may also use Application.Exit() method to close
the entire applicatin if you think it is suitable. This will correctly
inform all message pumps that they must terminate, and then close all
application windows after the messages have been processed based on the
MSDN. So I assume this method may meet your need.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 19 '07 #8
Hi Rodrigo,

Have you reviewed all the replies to you? Do they make sense to you? If you
still need any help or have any concern, please feel free to feedback,
thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 22 '07 #9

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

Similar topics

6
3223
by: DraguVaso | last post by:
Hi, In my application, on some given actions while debugging in Visual Studio, I suddenly get a "System.ComponentModel.Win32Exception was unhandled" Message="Error creating window handle."...
4
3621
by: Alpha | last post by:
I have a window Application. this.close(); doesn't stop and close my application when I get an error. Instead it continues trying to execute the following codes. What code do I need to the...
6
1510
by: Calligra | last post by:
have a form which looks at the title of the workbook saved on a different workbook, determines whether or not information has been inputted previously and then asks the user if the information is...
8
1771
by: jcrouse | last post by:
I am using the following code to trap errors in a sub routine: Try Executable code Catch ex As Exception Dim strInputE As String = Application.StartupPath & "\Error.txt" Dim srE As...
9
2085
by: Ron | last post by:
my application is throwing an exception error when closing if I run a procedure in the app. I can't even trap the error with try/catch ex As Exception. Is there a way to completely shut down the...
3
1348
by: Dennis | last post by:
I start my applicaiton from sub Main as follows: <STAThread()>Public Sub Main() Dim MainForm As frm_Main = New frm_Main Application.Run(MainForm) End Sub In the MainForm, I show a Progress...
5
5848
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
10
6931
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
0
7049
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,...
1
6744
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
6981
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...
1
4790
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4488
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...
0
3000
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1304
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 ...
1
565
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
188
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...

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.