Back to Devexpress

EnvironmentPolicy.ExitingProcess Event

corelibraries-devexpress-dot-data-dot-utils-dot-environmentpolicy-4a6fe55d.md

latest3.9 KB
Original Source

EnvironmentPolicy.ExitingProcess Event

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

Declaration

csharp
public static event EventHandler<EnvironmentPolicy.ExitingProcessEventArgs> ExitingProcess
vb
Public Shared Event ExitingProcess As EventHandler(Of EnvironmentPolicy.ExitingProcessEventArgs)

Event Data

The ExitingProcess event's data class is EnvironmentPolicy.ExitingProcessEventArgs. The following properties provide information specific to this event:

PropertyDescription
CancelGets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
ExceptionGets the exception.
ExitCodeGets or sets the exit code of the process.
MessageGets the error message.

The event data class exposes the following methods:

MethodDescription
ToString()Returns a human-readable representation of the ExitingProcessEventArg object, which can be useful for debugging, logging, or understanding the failure.

Remarks

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.

csharp
[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;
    }
}
vb
<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

SuppressExitProcess()

EnvironmentPolicy Class

EnvironmentPolicy Members

DevExpress.Data.Utils Namespace