'WinForms
Application.Exit();
'WPF
Application.Shutdown();
'Console
Environment.Exit(exitCode);
Can anyone list the advantages/disadvantages of above methods.
When to use, how to use etc..
Dont post any links or copy paste, this for knowledge sharing from persons who already experienced with above methods.
Loading

VulpesPosted Mar 9, 2011, 10:30 AM
Application.Shutdown() is (broadly) the equivalent of Application.Exit() in a WPF application. However, you have a bit more control as you can set the ShutDownMode so that the application shuts down when the main window closes, the last window closes or only when this method is called.
Environment.Exit() kills all running threads and the process itself stone dead. This should only be used in WF or WPF as a last resort when the more graceful methods are not working for some reason. It can also be used to make an abrupt exit from a console application.
Jim SnyderPosted Sep 9, 2016, 2:56 PM
Jim SnyderPosted Sep 9, 2016, 2:40 PM
VulpesPosted Mar 10, 2011, 4:45 AM
return 0;
Sam HobbsPosted Mar 10, 2011, 12:04 AM