Application.Exit() vs End

  • Thread starter Thread starter Matthew
  • Start date Start date
M

Matthew

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

Matthew
 
Matthew said:
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...
 
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
 
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
 
Exit is exit,

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

Cor
 
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 said:
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.
 
So, what event is generated when a user clicks on the X button in the upper
right hand corner of the form? Thanks in advance.
Christopher Koeber
 
Christopher

mybase.closing and than
mybase.closed

You find that in the combobox at

formx events

I hope this helps?

Cor

"Christopher Kurtis Koeber"
 
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
 
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
 
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.
 
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.
 
Michael D. Ober said:
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.
 
Hi friends,

I am developing application in C#.net.
Could any one please let me know on click of Cancel button how can I
close my application.

Rita
 
Rita,

microsoft.public.dotnet.languages.csharp

is the best place for c# language related questions.

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top