corelibraries-devexpress-dot-data-dot-utils-dot-environmentpolicy-4a6fe55d.md
Fires when the DevExpress control attempts to exit the current process. Handle this event to allow or suppress the operation.
Namespace : DevExpress.Data.Utils
Assembly : DevExpress.Data.v25.2.dll
NuGet Package : DevExpress.Data
public static event EventHandler<EnvironmentPolicy.ExitingProcessEventArgs> ExitingProcess
Public Shared Event ExitingProcess As EventHandler(Of EnvironmentPolicy.ExitingProcessEventArgs)
The ExitingProcess event's data class is EnvironmentPolicy.ExitingProcessEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Cancel | Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs. |
| Exception | Gets the exception. |
| ExitCode | Gets or sets the exit code of the process. |
| Message | Gets the error message. |
The event data class exposes the following methods:
| Method | Description |
|---|---|
| ToString() | Returns a human-readable representation of the ExitingProcessEventArg object, which can be useful for debugging, logging, or understanding the failure. |
Use the e.ExitCode event parameter to obtain and/or modify the exit code of the process. Set the e.Cancel event parameter to true to suppress the operation.
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
DevExpress.Data.Utils.EnvironmentPolicy.ExitingProcess += EnvironmentPolicy_ExitingProcess;
Application.Run(new Form1());
}
static void EnvironmentPolicy_ExitingProcess(object sender, DevExpress.Data.Utils.EnvironmentPolicy.ExitingProcessEventArgs e) {
if (e.ExitCode != 0) {
Log.Append(e.Message);
e.ExitCode = 0;
}
}
<STAThread>
Shared Sub Main()
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
AddHandler DevExpress.Data.Utils.EnvironmentPolicy.ExitingProcess, AddressOf EnvironmentPolicy_ExitingProcess
Application.Run(New Form1())
End Sub
Shared Sub EnvironmentPolicy_ExitingProcess(ByVal sender As Object, ByVal e As DevExpress.Data.Utils.EnvironmentPolicy.ExitingProcessEventArgs)
If e.ExitCode <> 0 Then
Log.Append(e.Message)
e.ExitCode = 0
End If
End Sub
Tip
Read the following topic for additional information: Environment Policy.
See Also