473,386 Members | 1,610 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,386 software developers and data experts.

Application.Exit() vs End

Is there any difference between Application.Exit() and End?
Are there circumstances when I should use one instead of the other?

Matthew
Nov 21 '05 #1
13 12450
"Matthew" <tu*************@alltel.net> schrieb:
Is there any difference between Application.Exit() and End?
Are there circumstances when I should use one instead of the other?


You should try to avoid using both of them...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #2
> You should try to avoid using both of them...

Thanks for the comment. I have a context menu with a "Exit" option. Is
there an alternative that I am not aware of?

Also, assuming it is one or the other, is there a difference?

Thank,

Matthew
Nov 21 '05 #3
So then how should you close your application?

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:e1**************@TK2MSFTNGP10.phx.gbl...
"Matthew" <tu*************@alltel.net> schrieb:
Is there any difference between Application.Exit() and End?
Are there circumstances when I should use one instead of the other?


You should try to avoid using both of them...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #4
Chrisotpher

Close the baseform
with me.close

And never use End, that is killing your application not closing it.

I write forever that poweroff is better than End.

Cor
Nov 21 '05 #5
Exit is exit,

End is ending your application direct, it stays in memory however it stops
processesing and stays there probably until powerdown.

Cor
Nov 21 '05 #6
The use of End without a further keyword such as Sub or Class, is not
supported and should not be used. Exit is used to terminate a block of code
for example. In this example anything after Exit Sub would not be executed.

Sub Mine()

'First Statement

Exit Sub

'Second Statement

End Sub

As others suggest You should close all your open resources and then cleanly
exit by either closeing the base form or getting to the end of your Sub Main
if thats how you started the application.

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"Matthew" <tu*************@alltel.net> wrote in message
news:Oh*************@TK2MSFTNGP11.phx.gbl...
You should try to avoid using both of them...


Thanks for the comment. I have a context menu with a "Exit" option. Is
there an alternative that I am not aware of?

Also, assuming it is one or the other, is there a difference?

Thank,

Matthew

Nov 21 '05 #7
"Matthew" <tu*************@alltel.net> schrieb:
You should try to avoid using both of them...


Thanks for the comment. I have a context menu with a "Exit" option. Is
there an alternative that I am not aware of?


\\\
Me.Close()
///

.... if it is your main form. If there are other forms, you should close
them before closing the main form.

Depending on how your application's message loop was started,
'Application.ExitThread' might be necessary to exit the application after
closing the forms. Make sure you take a look at the 'ApplicationContext'
class too.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #8
> Me.Close() if it is your main form. If there are other forms, you
should close them before closing the main form.


Thanks, I'll use that from now on.

Matthew
Nov 21 '05 #9
> The use of End without a further keyword such as Sub or Class, is not
supported and should not be used. Exit is used to terminate a block of
code for example. In this example anything after Exit Sub would not be
executed.


I'm sure you are right. However, I picked up this nasty habit from the book
Step by Step (version 2003).
Quoting from the end of page 113:
"The End statement stops the program when the user is finished."
In the sample programs provided, that method is used whenever he wants to
stop the program.

Strange stuff...

Matthew
Nov 21 '05 #10
Nak
Hi,
I'm sure you are right. However, I picked up this nasty habit from the
book Step by Step (version 2003).
Quoting from the end of page 113:
"The End statement stops the program when the user is finished."
In the sample programs provided, that method is used whenever he wants to
stop the program.


Christ, it just goes to show that people who teach don't know
everything! I remember reading a book once for VB6 that recommended storing
variables in hidden label controls!! What a b~O_d+G-e!

Nick.
Nov 21 '05 #11
In VB6, you can loop through the forms collection and close each form. I
know that the forms collection doesn't exist in .Net so how is this done.

Mike Ober.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eR****************@TK2MSFTNGP10.phx.gbl...

... if it is your main form. If there are other forms, you should close
them before closing the main form.

Depending on how your application's message loop was started,
'Application.ExitThread' might be necessary to exit the application after
closing the forms. Make sure you take a look at the 'ApplicationContext'
class too.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #12
"Michael D. Ober" <mdo.@.wakeassoc..com> schrieb:
In VB6, you can loop through the forms collection
and close each form. I know that the forms collection
doesn't exist in .Net so how is this done.


You will have to maintain such a collection yourself.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #13
Thanks.

Mike.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eC**************@TK2MSFTNGP10.phx.gbl...
"Michael D. Ober" <mdo.@.wakeassoc..com> schrieb:
In VB6, you can loop through the forms collection
and close each form. I know that the forms collection
doesn't exist in .Net so how is this done.


You will have to maintain such a collection yourself.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #14

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

Similar topics

1
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...
1
by: Brendan Miller | last post by:
I am trying to close my application using Application.exit() in the frmMain_Closing event. When the form closes the process does not. My application only has one form (no other classes either). ...
6
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...
1
by: Ioannis Vranos | last post by:
I am currently reading a chapter involving multithreading, and some sample code calls Environment::Exit() to terminate the application with all threads. What is the difference from...
4
by: Bob Day | last post by:
Using VS 2003, VB.net... I am confused about the Application.Exit method, where the help states "This method does not force the application to exit." Aside from the naming confusion, how do I...
3
by: oktave | last post by:
Hi, Anybody would like to tell me ther defference between Application.Exit() and End? I can use End to end my application no matter how many forms and codes after the End statement. But since...
22
by: Shelby | last post by:
Hi, I used System.Windows.Forms.Application.DoEvents() in a loop to handle user click close button . Private Sub btnclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)...
2
by: Mike Johnson | last post by:
The sub is being called from the Sub New(). If I can't use Application.Exit() in this situation then how do I exit the application? please help. Public Sub Check_For_Dir() Dim MyPath, MyName As...
4
by: JIM.H. | last post by:
Here is the code I am having problem: static void Main(string args) { bool isPar = false; if ((args.Length == 1)) { if ((args(0).ToUpper() == "MYPAR")) { isPar = true;
1
by: =?Utf-8?B?VGFvZ2U=?= | last post by:
Hi All, When I use applcation.exit() in winForm application, the form closed, but the process is still going!! ( The debug process is still running if debug in VS IDE). Environment.Exit(0) works...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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
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
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...

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.