Skip to main content
All docs
V24.2

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.v24.2.dll

Declaration

public static event EventHandler<EnvironmentPolicy.ExitingProcessEventArgs> ExitingProcess

Event Data

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.

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.

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

Tip

Read the following topic for additional information: Environment Policy.

See Also