Szerkesztés

Megosztás a következőn keresztül:


FileSystemWatcher.SynchronizingObject Property

Definition

Gets or sets the object used to marshal the event handler calls issued as a result of a directory change.

public:
 property System::ComponentModel::ISynchronizeInvoke ^ SynchronizingObject { System::ComponentModel::ISynchronizeInvoke ^ get(); void set(System::ComponentModel::ISynchronizeInvoke ^ value); };
public System.ComponentModel.ISynchronizeInvoke? SynchronizingObject { get; set; }
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject { get; set; }
[System.IO.IODescription("FSW_SynchronizingObject")]
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject { get; set; }
[System.IO.IODescription("FSW_SynchronizingObject")]
[System.ComponentModel.Browsable(false)]
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject { get; set; }
[System.ComponentModel.Browsable(false)]
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject { get; set; }
member this.SynchronizingObject : System.ComponentModel.ISynchronizeInvoke with get, set
[<System.IO.IODescription("FSW_SynchronizingObject")>]
member this.SynchronizingObject : System.ComponentModel.ISynchronizeInvoke with get, set
[<System.IO.IODescription("FSW_SynchronizingObject")>]
[<System.ComponentModel.Browsable(false)>]
member this.SynchronizingObject : System.ComponentModel.ISynchronizeInvoke with get, set
[<System.ComponentModel.Browsable(false)>]
member this.SynchronizingObject : System.ComponentModel.ISynchronizeInvoke with get, set
Public Property SynchronizingObject As ISynchronizeInvoke

Property Value

The ISynchronizeInvoke that represents the object used to marshal the event handler calls issued as a result of a directory change. The default is null.

Attributes

Remarks

When SynchronizingObject is null, methods handling the Changed, Created, Deleted, and Renamed events are called on a thread from the system thread pool. For more information on system thread pools, see ThreadPool.

When the Changed, Created, Deleted, and Renamed events are handled by a visual Windows Forms component, such as a Button, accessing the component through the system thread pool might not work, or may result in an exception. Avoid this by setting SynchronizingObject to a Windows Forms component, which causes the methods that handle the Changed, Created, Deleted, and Renamed events to be called on the same thread on which the component was created.

If the FileSystemWatcher is used inside Visual Studio 2005 in a Windows Forms designer, SynchronizingObject automatically sets to the control that contains the FileSystemWatcher. For example, if you place a FileSystemWatcher on a designer for Form1 (which inherits from Form) the SynchronizingObject property of FileSystemWatcher is set to the instance of Form1.

Applies to

See also