Application.Exit Method ()
Informs all message pumps that they must terminate, and then closes all application windows after the messages have been processed.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
raises the following events and performs the associated conditional actions:
If one of more of the handlers cancels the event, then FormClosed event is raised for every open form, then all running message loops and forms are closed.returns without further action. Otherwise, a
The following code example lists numbers in a list box on a form. Each time you click button1, the application adds another number to the list.
The Main method calls Run to start the application, which creates the form, listBox1, and button1. When the user clicks button1, the button1_Click method adds numbers one to three to the list box, and displays a MessageBox. If the user clicks No on the MessageBox, the button1_Click method adds another number to the list. If the user clicks Yes, the application calls , to process all remaining messages in the queue and then to quit.
The example requires that listBox1 and button1 have been instantiated and placed on a form.
Available since 1.1