SortedDictionary<TKey,TValue>.ValueCollection.ICollection.IsSynchronized 属性


获取一个值,该值指示是否同步对 ICollection 的访问(线程安全)。Gets a value indicating whether access to the ICollection is synchronized (thread safe).

property bool System::Collections::ICollection::IsSynchronized { bool get(); };
bool System.Collections.ICollection.IsSynchronized { get; }
 ReadOnly Property IsSynchronized As Boolean Implements ICollection.IsSynchronized


如果对 true 的访问是同步的(线程安全),则为 ICollection;否则为 falsetrue if access to the ICollection is synchronized (thread safe); otherwise, false. SortedDictionary<TKey,TValue>.ValueCollection 的默认实现中,此属性始终返回 falseIn the default implementation of SortedDictionary<TKey,TValue>.ValueCollection, this property always returns false.



System.Collections.Generic 命名空间中集合的默认实现是不同步的。Default implementations of collections in the System.Collections.Generic namespace are not synchronized.

枚举整个集合本质上不是一个线程安全的过程。Enumerating through a collection is intrinsically not a thread-safe procedure. 若要确保枚举过程中的线程安全性,可以在整个枚举过程中锁定集合。To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. 若要允许多个线程访问集合以进行读写操作,则必须实现自己的同步。To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.

@No__t-0 属性返回一个对象,该对象可用于同步对 @no__t 的访问。The SyncRoot property returns an object that can be used to synchronize access to the ICollection. 仅当所有线程在访问集合之前锁定对象时,同步才有效。Synchronization is effective only if all threads lock the object before accessing the collection.

获取此属性的值的运算复杂度为 O (1)。Getting the value of this property is an O(1) operation.