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.
- Difference between a Value Type and a Reference Type
- System level Exceptions Vs Application level Exceptions
- Difference between sub-procedure and function
- What does the term immutable mean
- What does the keyword static mean
- Difference between a.Equals(b) and a == b
- Difference between Hashtable and Dictionary
- Difference between Exception and Error
- C# Dictionary Versus List Lookup Time
- Difference between the Class and Interface in C#
- Why does C# doesn't support Multiple inheritance