ActivityCollection.ICollection.SyncRoot Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets an object that can be used to synchronize access to the ICollection<T>.
property System::Object ^ System::Collections::ICollection::SyncRoot { System::Object ^ get(); };
object System.Collections.ICollection.SyncRoot { get; }
member this.System.Collections.ICollection.SyncRoot : obj
ReadOnly Property SyncRoot As Object Implements ICollection.SyncRoot
Property Value
An object that can be used to synchronize access to the ICollection<T>.
Implements
Remarks
For collections whose underlying store is not publicly available, the expected implementation is to return the current instance. Note that the pointer to the current instance might not be sufficient for collections that wrap other collections; those should return the underlying collection SyncRoot property.
Most collection classes in the System.Collections namespace also implement a Synchronized
method, which provides a synchronized wrapper around the underlying collection. However, derived classes can provide their own synchronized version of the collection using the ICollection.SyncRoot property. The synchronizing code must perform operations on the ICollection.SyncRoot property of the collection, not directly on the collection. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the collection instance.
Applies to
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應