What is the C# equivalent to Java's System.exit(0);?
How do I terminate a C# program?
Page 1 of 15 Replies - 1495 Views - Last Post: 06 August 2011 - 01:18 PM
Replies To: How do I terminate a C# program?
#2
Re: How do I terminate a C# program?
Posted 06 August 2011 - 12:57 PM
I don't know if it is equal to the Java call you mentioned, but to terminate a C# program you either close the main form or can call
Personally I would suggest you close the main form. That way you can react to the .Closing event to clean up any resources, ask the user to confirm they want to close the application, save any changed settings/preferences, save any open documents and other tidy-ing up and housekeeping you might have.
Application.Exit();
Personally I would suggest you close the main form. That way you can react to the .Closing event to clean up any resources, ask the user to confirm they want to close the application, save any changed settings/preferences, save any open documents and other tidy-ing up and housekeeping you might have.
#4
Re: How do I terminate a C# program?
Posted 06 August 2011 - 01:09 PM
Thank you all.
#5
Re: How do I terminate a C# program?
Posted 06 August 2011 - 01:13 PM
Now I'm curious. In real-world uses how is that different than telling your application to .exit()?
And for answering the title question
I would think Application.Exit() to be a better choice. Or do you know an advantage with Environment.Exit()?
And for answering the title question
Quote
How Do I Terminate A C# Program?
I would think Application.Exit() to be a better choice. Or do you know an advantage with Environment.Exit()?
#6
Re: How do I terminate a C# program?
Posted 06 August 2011 - 01:18 PM
Environment.Exit allows you to return a value so you can indicate something about the processing (like to a batch file).
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|