473,498 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Exit an application properly on Error

Rob
I have the following code...

Try
da.Fill(ds,"myset")
Catch exc as exception
Msgbox("Check Connection string Info")
Ffrm.Dispose()
Application.Exit()
Exit Sub
EndTry

I noticed that the Application.Exit() alone did not exit the Sub
Procedure... so I added the Exit Sub. Why doesn't Application.Exit()
alone work ?

Thanks!
Jan 14 '06 #1
8 1172
Hello,

You could try End.

You can also set all forms and classes to Nothing

myForm = Nothing

And then call End. I think Application.Exit waits for the message queue to
finish proccessing... Maybe that is why it did not exit immediately.

Regards
Cyril Gupta
Jan 14 '06 #2
Rob
End works...

Regarding... "You can also set all forms and classes to Nothing"

Is there some generic code that one can run that will loop thru all "open"
objects and sets them to nothing ?

Thanks !

"Cyril Gupta" <no****@mail.com> wrote in message
news:Oq**************@TK2MSFTNGP15.phx.gbl...
Hello,

You could try End.

You can also set all forms and classes to Nothing

myForm = Nothing

And then call End. I think Application.Exit waits for the message queue to
finish proccessing... Maybe that is why it did not exit immediately.

Regards
Cyril Gupta

Jan 14 '06 #3
"Rob" <rw*****@comcast.net> schrieb:
Regarding... "You can also set all forms and classes to Nothing"

Is there some generic code that one can run that will loop thru all "open"
objects and sets them to nothing ?


Setting the variables pointing to forms to 'Nothing' doesn't make much
sense. Instead, you may want to call the main form's 'Close' method and/or
the forms' 'Close' methods.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 14 '06 #4
Using end to just end the lifecycle of an application is considered bad
coding practice

you should use End sparingly and only when you need and can terminate
immediatly ( normally you can`t , that is why it is bad coding practice :-)

http://msdn.microsoft.com/library/de...l/vastmend.asp

The right way to end an application is to clean / interupt the calling
chain

regards

Michel Posseth [MCP]

"Rob" <rw*****@comcast.net> wrote in message
news:lp********************@comcast.com...
End works...

Regarding... "You can also set all forms and classes to Nothing"

Is there some generic code that one can run that will loop thru all "open"
objects and sets them to nothing ?

Thanks !

"Cyril Gupta" <no****@mail.com> wrote in message
news:Oq**************@TK2MSFTNGP15.phx.gbl...
Hello,

You could try End.

You can also set all forms and classes to Nothing

myForm = Nothing

And then call End. I think Application.Exit waits for the message queue
to finish proccessing... Maybe that is why it did not exit immediately.

Regards
Cyril Gupta


Jan 14 '06 #5
Rob
Thanks Michel,

So my question kind of still remains... before using an "End" or even "Exit
Sub"....

Is there some generic code that will loop thru all "open"
objects and clean them up ?

"m.posseth" <mi*****@nohausystems.nl> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
Using end to just end the lifecycle of an application is considered bad
coding practice

you should use End sparingly and only when you need and can terminate
immediatly ( normally you can`t , that is why it is bad coding practice
:-)

http://msdn.microsoft.com/library/de...l/vastmend.asp

The right way to end an application is to clean / interupt the calling
chain

regards

Michel Posseth [MCP]

"Rob" <rw*****@comcast.net> wrote in message
news:lp********************@comcast.com...
End works...

Regarding... "You can also set all forms and classes to Nothing"

Is there some generic code that one can run that will loop thru all
"open" objects and sets them to nothing ?

Thanks !

"Cyril Gupta" <no****@mail.com> wrote in message
news:Oq**************@TK2MSFTNGP15.phx.gbl...
Hello,

You could try End.

You can also set all forms and classes to Nothing

myForm = Nothing

And then call End. I think Application.Exit waits for the message queue
to finish proccessing... Maybe that is why it did not exit immediately.

Regards
Cyril Gupta



Jan 14 '06 #6

Rob ,,

Not that i know of ,,,, however it shouldn`t be necesary to do so cleaning
up the base object should result in the disposing of evenntuall satelites

if you need to use End to stop an app this means that something is wrong in
your apps design
regards

Michel Posseth [MCP]
"Rob" <rw*****@comcast.net> wrote in message
news:Hd********************@comcast.com...
Thanks Michel,

So my question kind of still remains... before using an "End" or even
"Exit Sub"....

Is there some generic code that will loop thru all "open"
objects and clean them up ?

"m.posseth" <mi*****@nohausystems.nl> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
Using end to just end the lifecycle of an application is considered bad
coding practice

you should use End sparingly and only when you need and can terminate
immediatly ( normally you can`t , that is why it is bad coding practice
:-)

http://msdn.microsoft.com/library/de...l/vastmend.asp

The right way to end an application is to clean / interupt the calling
chain

regards

Michel Posseth [MCP]

"Rob" <rw*****@comcast.net> wrote in message
news:lp********************@comcast.com...
End works...

Regarding... "You can also set all forms and classes to Nothing"

Is there some generic code that one can run that will loop thru all
"open" objects and sets them to nothing ?

Thanks !

"Cyril Gupta" <no****@mail.com> wrote in message
news:Oq**************@TK2MSFTNGP15.phx.gbl...
Hello,

You could try End.

You can also set all forms and classes to Nothing

myForm = Nothing

And then call End. I think Application.Exit waits for the message queue
to finish proccessing... Maybe that is why it did not exit immediately.

Regards
Cyril Gupta



Jan 14 '06 #7
Rob
Let's say you have code that is going to fill a data set via a Command
object / stored proc...
If the connection string is bad (held in the config file) OR a stored proc
is missing (the one you are calling)... then for all intents and purposes my
program may as well shut down...

Do I only need to dispose of the Form ? what about any connections ? other
varibales ? What is left over as a "problem" if the application just "Ends"
at this point ?

Thanks,
Rob

"m.posseth" <mi*****@nohausystems.nl> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...

Rob ,,

Not that i know of ,,,, however it shouldn`t be necesary to do so cleaning
up the base object should result in the disposing of evenntuall
satelites

if you need to use End to stop an app this means that something is wrong
in your apps design
regards

Michel Posseth [MCP]
"Rob" <rw*****@comcast.net> wrote in message
news:Hd********************@comcast.com...
Thanks Michel,

So my question kind of still remains... before using an "End" or even
"Exit Sub"....

Is there some generic code that will loop thru all "open"
objects and clean them up ?

"m.posseth" <mi*****@nohausystems.nl> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
Using end to just end the lifecycle of an application is considered bad
coding practice

you should use End sparingly and only when you need and can terminate
immediatly ( normally you can`t , that is why it is bad coding practice
:-)

http://msdn.microsoft.com/library/de...l/vastmend.asp

The right way to end an application is to clean / interupt the calling
chain

regards

Michel Posseth [MCP]

"Rob" <rw*****@comcast.net> wrote in message
news:lp********************@comcast.com...
End works...

Regarding... "You can also set all forms and classes to Nothing"

Is there some generic code that one can run that will loop thru all
"open" objects and sets them to nothing ?

Thanks !

"Cyril Gupta" <no****@mail.com> wrote in message
news:Oq**************@TK2MSFTNGP15.phx.gbl...
> Hello,
>
> You could try End.
>
> You can also set all forms and classes to Nothing
>
> myForm = Nothing
>
> And then call End. I think Application.Exit waits for the message
> queue to finish proccessing... Maybe that is why it did not exit
> immediately.
>
> Regards
> Cyril Gupta
>



Jan 14 '06 #8
Well in my opinion your program should in the described situation raise an
exception , and so shutdown

regards

Michel Posseth [MCP]

"Rob" <rw*****@comcast.net> wrote in message
news:7v********************@comcast.com...
Let's say you have code that is going to fill a data set via a Command
object / stored proc...
If the connection string is bad (held in the config file) OR a stored
proc is missing (the one you are calling)... then for all intents and
purposes my program may as well shut down...

Do I only need to dispose of the Form ? what about any connections ?
other varibales ? What is left over as a "problem" if the application
just "Ends" at this point ?

Thanks,
Rob

"m.posseth" <mi*****@nohausystems.nl> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...

Rob ,,

Not that i know of ,,,, however it shouldn`t be necesary to do so
cleaning up the base object should result in the disposing of evenntuall
satelites

if you need to use End to stop an app this means that something is wrong
in your apps design
regards

Michel Posseth [MCP]
"Rob" <rw*****@comcast.net> wrote in message
news:Hd********************@comcast.com...
Thanks Michel,

So my question kind of still remains... before using an "End" or even
"Exit Sub"....

Is there some generic code that will loop thru all "open"
objects and clean them up ?

"m.posseth" <mi*****@nohausystems.nl> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
Using end to just end the lifecycle of an application is considered
bad coding practice

you should use End sparingly and only when you need and can terminate
immediatly ( normally you can`t , that is why it is bad coding
practice :-)

http://msdn.microsoft.com/library/de...l/vastmend.asp

The right way to end an application is to clean / interupt the
calling chain

regards

Michel Posseth [MCP]

"Rob" <rw*****@comcast.net> wrote in message
news:lp********************@comcast.com...
> End works...
>
> Regarding... "You can also set all forms and classes to Nothing"
>
> Is there some generic code that one can run that will loop thru all
> "open" objects and sets them to nothing ?
>
> Thanks !
>
> "Cyril Gupta" <no****@mail.com> wrote in message
> news:Oq**************@TK2MSFTNGP15.phx.gbl...
>> Hello,
>>
>> You could try End.
>>
>> You can also set all forms and classes to Nothing
>>
>> myForm = Nothing
>>
>> And then call End. I think Application.Exit waits for the message
>> queue to finish proccessing... Maybe that is why it did not exit
>> immediately.
>>
>> Regards
>> Cyril Gupta
>>
>
>



Jan 14 '06 #9

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

Similar topics

1
8483
by: Guinness Mann | last post by:
Pardon me if this is not the optimum newsgroup for this post, but it's the only .NET newsgroup I read and I'm certain someone here can help me. I have a C# program that checks for an error...
7
7001
by: Darklight | last post by:
if the exit() function is contained in stdlid.h why if i remove the above header file the exit function still works and i can still compile program without any error messages using cc file.c if i...
11
29638
by: Peter Steele | last post by:
I have a Windows application written in C# that I want to return a non-zero exit code when it it run. The problem is that as a Windows application, there doesn't seem to be a way to control this....
6
20035
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
12
2612
by: Pete Smith | last post by:
Which is the appropriate one to use in the above choice? VB.Net. .Net Framework 1.1 Thank you, Pete
3
2022
by: ESmith | last post by:
When a user starts up my application, I want to check for some prerequisite conditions, and if not met, the exit the application. Example: public Form1() { InitializeComponent(); if (...
1
7018
by: Chris Cairns | last post by:
I have a MDI Application and would like to prompt the user before exit. I placed the following in the FormClosing event. It appears to work properly, however when a user answers no to the...
2
18220
by: Navaneet | last post by:
Hi, I am building a application on linux. I am getting an error which relates to undefined reference to a function. I had build same on other platform, no error comes. Here is whole error...
34
4973
by: Drake | last post by:
I have a general question of Python style, or perhaps just good programming practice. My group is developing a medium-sized library of general-purpose Python functions, some of which do I/O....
0
7121
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
6993
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
7162
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
7197
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...
1
6881
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
5456
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,...
1
4899
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
3088
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...
1
650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.