FileSystemWatcher.SynchronizingObject FileSystemWatcher.SynchronizingObject FileSystemWatcher.SynchronizingObject FileSystemWatcher.SynchronizingObject Property

定義

取得或設定物件,用以封送處理因目錄變更而發出的事件處理常式呼叫。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); };
[System.ComponentModel.Browsable(false)]
[System.IO.IODescription("The object used to marshal the event handler calls resulting from a directory change")]
[System.IO.IODescription("FSW_SynchronizingObject")]
public System.ComponentModel.ISynchronizeInvoke SynchronizingObject { get; set; }
member this.SynchronizingObject : System.ComponentModel.ISynchronizeInvoke with get, set
Public Property SynchronizingObject As ISynchronizeInvoke

屬性值

ISynchronizeInvoke,表示用以封送處理因目錄變更而發出的事件處理常式呼叫的物件。The ISynchronizeInvoke that represents the object used to marshal the event handler calls issued as a result of a directory change. 預設為 nullThe default is null.

備註

SynchronizingObjectCreated Changed Renamed Deleted時,會在系統執行緒集區的執行緒上呼叫處理、、和事件的方法。 nullWhen SynchronizingObject is null, methods handling the Changed, Created, Deleted, and Renamed events are called on a thread from the system thread pool. 如需系統執行緒集區的詳細資訊ThreadPool,請參閱。For more information on system thread pools, see ThreadPool.

Changed當、 Created、和事件Renamed由 visual Windows Forms 元件(例如Button)處理時,透過系統執行緒集區存取元件可能無法正常執行,或可能會導致例外狀況。 DeletedWhen 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. 若要避免這SynchronizingObject種情況,請將設定為 Windows Forms 元件,這會Changed導致Created處理Deleted、、 Renamed和事件的方法,在建立該元件的相同執行緒上呼叫。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.

如果在 Windows Forms 設計工具Visual Studio 2005Visual Studio 2005內使用, SynchronizingObjectFileSystemWatcher會自動將設定為包含的控制項。 FileSystemWatcherIf the FileSystemWatcher is used inside Visual Studio 2005Visual Studio 2005 in a Windows Forms designer, SynchronizingObject automatically sets to the control that contains the FileSystemWatcher. 例如, FileSystemWatcher如果您將放在 form1 的設計工具上(繼承自Form),則SynchronizingObject的屬性FileSystemWatcher會設定為 form1 的實例。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.

適用於

另請參閱