System.Diagnostics.Process.SynchronizingObject Property

Gets or sets the object used to marshal the event handler calls that are issued as a result of a process exit event.

Syntax

[System.ComponentModel.Browsable(false)]
[System.ComponentModel.DefaultValue(null)]
[System.Diagnostics.MonitoringDescription("The object that is used to synchronize event handler calls for this process.")]
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject { get; set; }

Value

Documentation for this section has not yet been entered.

Remarks

When EventLog.SynchronizingObject is null, methods that handle the Process.Exited event are called on a thread from the system thread pool. For more information about system thread pools, see System.Threading.ThreadPool.

When the Process.Exited event is handled by a visual Windows Forms component, such as a System.Windows.Forms.Button, accessing the component through the system thread pool might not work, or might result in an exception. Avoid this by setting Process.SynchronizingObject to a Windows Forms component, which causes the methods handling the Process.Exited event to be called on the same thread on which the component was created.

If the System.Diagnostics.Process is used inside vsprvslong in a Windows Forms designer, Process.SynchronizingObject is automatically set to the control that contains the System.Diagnostics.Process. For example, if you place a System.Diagnostics.Process on a designer for Form1 (which inherits from System.Windows.Forms.Form) the Process.SynchronizingObject property of System.Diagnostics.Process is set to the instance of Form1:

code reference: Process_SynchronizingObject#2

Typically, this property is set when the component is placed inside a control or form, because those components are bound to a specific thread.

Requirements

Namespace: System.Diagnostics
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0