pmMDA.NET

PagedListBase.IsSynchronized Property

[This is preliminary documentation and subject to change.]

Gets whether the access to this list is synchronized (thread-safe).

public bool IsSynchronized {get;}

Property Value

Always false.

Implements

ICollection.IsSynchronized

Remarks

SyncRoot returns an object, which can be used to synchronize the access to this list.

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

[Visual Basic, C#]

Example

The following code example shows how to lock the list using the SyncRoot during the entire iteration:

PagedListBase myList = new PagedList(/*...*/);
lock( myList.SyncRoot ) {
  foreach (IDataObject item in myList) {
    // Insert your code here.
  }
}

See Also

PagedListBase Class | PmMda.Net.Dog.Paging Namespace