Answered by:
FAQ Item: Does Application.Exit() method affect FormClosing event?

Question
-
Answers
-
Exit raises the following events and performs the associated conditional actions:
1. A FormClosing event is raised for every form represented by the OpenForms property. This event can be canceled by setting the Cancel property of its FormClosingEventArgs parameter to true.
2. If one of more of the handlers cancels the event, then Exit returns without further action. Otherwise, a FormClosed event is raised for every open form, and then all running message loops and forms are closed.
Prior to .NET Framework version 2.0, the Exit method did not raise the equivalent events for the Form class (Closed and Closing). In order to force these events, it was necessary to explicitly call the Close method for each open form before calling the Exit method.
Related threads:
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Marked as answer by Ji.Zhou Friday, March 5, 2010 6:58 AM
All replies
-
Exit raises the following events and performs the associated conditional actions:
1. A FormClosing event is raised for every form represented by the OpenForms property. This event can be canceled by setting the Cancel property of its FormClosingEventArgs parameter to true.
2. If one of more of the handlers cancels the event, then Exit returns without further action. Otherwise, a FormClosed event is raised for every open form, and then all running message loops and forms are closed.
Prior to .NET Framework version 2.0, the Exit method did not raise the equivalent events for the Form class (Closed and Closing). In order to force these events, it was necessary to explicitly call the Close method for each open form before calling the Exit method.
Related threads:
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Marked as answer by Ji.Zhou Friday, March 5, 2010 6:58 AM
-
The Form.Closed and Form.Closing events are not raised when the Application.Exit method is called to exit your application. If you have validation code in either of these events that must be executed, you should call the Form.Close method for each open form individually before calling the Exit method.
Related Threads:-
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.closing.aspx
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Ambesha
- Proposed as answer by Ambesh Kumar Singh Thursday, August 30, 2012 9:07 AM