Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ending an application

Status
Not open for further replies.

sodakotahusker

Programmer
Mar 15, 2001
601
I know that the END statement still seems to work.
I have seen in demostrations however the use of a terminate or something method to end an application. I am thinking that I should use them instead of END. Can someone tell me what the statement is?
 
Code:
Application.Exit

This will terminate an application.

Jay
 
I thought that was it but application does not appear to be a valid object. I have a squiggly line under it and there was no intellisense. I assume that means I need to import another namespace?
 
Here is an article that talks about the different ways to exit from an application.



As I suspected - using END was not recommended cause it does a total shutdown without invoking the Finalize method.

I think this is not working for me because I am creating a console application and the exit seems to require forms to be referenced?
 
I think this is not working for me because I am creating a console application and the exit seems to require forms to be referenced?

Yes, it looks like Application.Exit requires Windows Forms to be loaded. Based on my experience, the only good way to exit out of a console application is to call Environment.Exit(-1) (or another error code if something goes wrong). I don't think that you have to have security permissions set if you call that line from a console application, though I could be wrong.

Jay
 
Thanks! environment.exit seems to work just fine. I was curious where would the information be available so that you could check the exit value and see if the process ran successfully or hit a snab and abended?

PS: referencing the environment object just opened up a new world to me. I already replace my command$ variable with the getcommandlineargs and wrote a line to pull the current user.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top