I = i + 1 listBox1.Items.Add(i) End While ' The user wants to exit the application. Close everything down. Application.Exit End Sub Remarks. The Exit method stops all running message loops on all threads and closes all windows of the application. This method does not necessarily force the application to exit.
-->
Definizione
Si verifica poco prima dell'arresto di un'applicazione e non può essere annullato.Occurs just before an application shuts down, and cannot be canceled.
![]() Esempi
Nell'esempio seguente viene illustrato come:The following example demonstrates how to:
Commenti
Un'applicazione può essere arrestata per uno dei seguenti motivi:An application can shut down for either of the following reasons:
È possibile rilevare quando si verifica l'arresto dell'applicazione Exit gestendo l'evento ed eseguire qualsiasi elaborazione aggiuntiva in base alle esigenze.You can detect when application shutdown occurs by handling the Exit event, and perform any additional processing as required.
È anche possibile gestire Exit per controllare o modificare il codice di uscita dell'applicazione quando non è necessario Shutdown chiamare in modo esplicito.You can also handle Exit to inspect or change the application exit code when you don't need to call Shutdown explicitly.Il codice ApplicationExitCodeExit di uscita viene esposto dalla proprietà dell' argomentopassatoalgestoreeventi.ExitEventArgsThe exit code is exposed from the ApplicationExitCode property of the ExitEventArgs argument that's passed to the Exit event handler.Quando l'esecuzione dell'applicazione viene arrestata, il codice di uscita viene passato al sistema operativo per l'elaborazione successiva.When the application stops running, the exit code is passed to the operating system for subsequent processing.
Se l'applicazione gestisce l' SessionEnding evento e successivamente lo Annulla, Exit non viene generato e l'esecuzione dell'applicazione continua in base alla modalità di arresto.If your application handles the SessionEnding event and subsequently cancels it, Exit is not raised and the application continues running in accordance with the shutdown mode.
Il codice di uscita può essere impostato da applicazione browser XAML (XBAP)XAML browser application (XBAP), anche se il valore viene ignorato.The exit code can be set from an applicazione browser XAML (XBAP)XAML browser application (XBAP), although the value is ignored.
Per XBAPXBAPs ,Exit viene generato nelle circostanze seguenti:For XBAPXBAPs, Exit is raised in the following circumstances:
In tutti i casi, il valore della ApplicationExitCode proprietà viene ignorato.In all cases, the value of the ApplicationExitCode property is ignored.
Si applica aVedi anche
Access On Exit EventDefinitionSpring Application Exit Event
Informs all message pumps that they must terminate, and then closes all application windows after the messages have been processed.
Overloads
Informs all message pumps that they must terminate, and then closes all application windows after the messages have been processed.
Examples
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 Exit, 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.
Remarks
The Exit method stops all running message loops on all threads and closes all windows of the application. This method does not necessarily force the application to exit. The Exit method is typically called from within a message loop, and forces Run to return. To exit a message loop for the current thread only, call ExitThread.
Exit raises the following events and performs the associated conditional actions:
Note
The Exit method does not raise the Closed and Closing events, which are obsolete as of .NET Framework 2.0.
Security
Removewat windows 8.1 download. SecurityPermission
for the immediate caller to call unmanaged code. Associated enumeration: UnmanagedCode
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |