Back to Devexpress

ProcessStartPolicy.Starting Event

corelibraries-devexpress-dot-data-dot-utils-dot-processstartpolicy-8ed14aed.md

latest3.2 KB
Original Source

ProcessStartPolicy.Starting Event

Fires before a process starts and allows you to cancel the process.

Namespace : DevExpress.Data.Utils

Assembly : DevExpress.Data.Desktop.v25.2.dll

NuGet Packages : DevExpress.Data.Desktop, DevExpress.ExpressApp.Win.Design

Declaration

csharp
public static event CancelEventHandler Starting
vb
Public Shared Event Starting As CancelEventHandler

Event Data

The Starting event's data class is CancelEventArgs. The following properties provide information specific to this event:

PropertyDescription
CancelGets or sets a value indicating whether the event should be canceled.

Remarks

Handle Starting and Started events to perform custom actions when a DevExpress UI control starts a process.

csharp
static void Main() {
  ProcessStartPolicy.Starting += ProcessStartPolicy_Starting;
  ProcessStartPolicy.Started += ProcessStartPolicy_Started;
  // ...
}
private static void ProcessStartPolicy_Starting(object sender, System.ComponentModel.CancelEventArgs e) {
  ProcessStartInfo psi = sender as ProcessStartInfo;
  e.Cancel = !psi.FileName.Contains("www.devexpress.com");
}
private static void ProcessStartPolicy_Started(object sender, EventArgs e) {
  Process process = sender as Process;
  // ...
  // Log.WriteMessage("process started");
}
vb
Shared Sub Main()
  AddHandler ProcessStartPolicy.Starting, AddressOf ProcessStartPolicy_Starting
  AddHandler ProcessStartPolicy.Started, AddressOf ProcessStartPolicy_Started
  ' ...
End Sub
Private Shared Sub ProcessStartPolicy_Starting(sender As Object, e As CancelEventArgs)
  Dim psi As ProcessStartInfo = CType(sender, ProcessStartInfo)
  e.Cancel = Not psi.FileName.Contains("www.devexpress.com")
End Sub
Private Shared Sub ProcessStartPolicy_Started(sender As Object, e As EventArgs)
  Dim process As Process = CType(sender, Process)
  ' ...
  ' Log.WriteMessage("process started")
End Sub

Read the following topic for more information: Suppress New Processes Initiated by .NET Controls.

See Also

Started

ProcessStartPolicy Class

ProcessStartPolicy Members

DevExpress.Data.Utils Namespace