BaseCollection.IsSynchronized BaseCollection.IsSynchronized BaseCollection.IsSynchronized BaseCollection.IsSynchronized Property


取得值,表示對 ICollection 的存取是否同步化。Gets a value indicating whether access to the ICollection is synchronized.

 property bool IsSynchronized { bool get(); };
public bool IsSynchronized { get; }
member this.IsSynchronized : bool
Public ReadOnly Property IsSynchronized As Boolean


這個屬性永遠會傳回 falseThis property always returns false.



如果集合具備執行緒安全,IsSynchronized屬性會傳回true,以及程式設計人員就不必採取任何動作來保護安全執行緒。If a collection is thread safe, the IsSynchronized property returns true, and the programmer does not have to do anything to keep the collection thread safe.

如果,正如同使用BaseCollection,則IsSynchronized屬性會傳回false,則SyncRoot屬性會傳回物件,可搭配 C#lock關鍵字。If, as is the case with the BaseCollection, the IsSynchronized property returns false, then the SyncRoot property returns an object that can be used with the C# lock keyword. 使用靜態EnterExit方法Monitor類別,以手動方式鎖定和解除鎖定的同步處理物件。Use the static Enter and Exit methods of the Monitor class to manually lock and unlock the synchronization object.