locked
FAQ Item: Does Application.Exit() method affect FormClosing event? RRS feed

  • Question

  • Does Application.Exit() method affect FormClosing event?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Monday, February 1, 2010 2:40 PM

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:

    http://social.msdn.microsoft.com/Forums/en-SG/csharpgeneral/thread/df8f1bd5-6d8d-4ccc-9c07-822210a7c943

    http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/5e957131-5c03-447e-b971-cb843b135f12


    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
    Monday, February 1, 2010 2:40 PM

All replies