List<T>.ICollection.IsSynchronized List<T>.ICollection.IsSynchronized List<T>.ICollection.IsSynchronized Property

定義

取得值,這個值表示對 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. List<T> 的預設實作中,這個屬性永遠會傳回 falseIn the default implementation of List<T>, 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. 在極少數的案例,其中列舉競用權限寫入,您可以鎖定整個列舉期間的集合。In the rare case where enumeration contends with write accesses, 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.

SyncRoot 傳回的物件,可用來同步存取ICollectionSyncRoot returns an object that can be used to synchronize access to the ICollection. 同步處理是所有執行緒存取集合之前都鎖定這個物件時,才有效。Synchronization is effective only if all threads lock this object before accessing the collection.

擷取這個屬性的值是一種 O(1) 運算。Retrieving the value of this property is an O(1) operation.

適用於

另請參閱