Thread Safety

Collection Thread Safety

Public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

This implementation does not provide a synchronized (thread safe) wrapper for a CollectionBase, but derived classes can create their own synchronized versions of the CollectionBase using the SyncRoot property.

Enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.

http://msdn2.microsoft.com/en-us/library/system.collections.collectionbase(VS.80).aspx

One Response to Thread Safety

  1. Iklan Gambar says:

    Iklan Gambar

    Thread Safety | Just to note and share about anything

Leave a comment