this.close() Vs Application.Exit()


this.Close() will call Form.Close method of current form. When a form is closed, all resources created within the object are closed and the form is disposed. Whenever you close your program's startup form, the entire application should exit automatically, including closing all other open forms in the same project otherwise it just close the current form.



System.Windows.Forms.Application.Exit() informs all message pumps that they must terminate, and then closes all application windows after the messages have been processed, so it giving your forms the possibility to execute their cleanup code.

In a multithreading program, Application.Exit() will not terminate all your threads instead you are only exiting from the current thread context, while leaving any started foreground threads running. In this case you should take measures to kill your other threads, either in the main function or when in the OnClose event of your main form.


Environment.Exit(0) terminates this process and gives the underlying operating system the specified exit code. It is more generally used in console applications.

 (C) 2023    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.
SiteMap  | Terms  | About