NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

ICollection.SyncRoot

When implemented by a class, retrieves an object that can be used to synchronize access to the ICollection.

[Visual Basic]
ReadOnly Property SyncRoot As Object
[C#]
object SyncRoot {get;}
[C++]
Object* get_SyncRoot() = 0;
[JScript]
abstract function get SyncRoot() : Object;

Property Value

An object that can be used to synchronize access to the ICollection.

Remarks

Collection classes in System.Collections also implement a GetSynchronized method, which provides a synchronized wrapper around the underlying collection.

For collections whose underlying store is not publicly available, the expected implementation is to simply return 'this'. Note that the 'this' pointer may not be sufficient for collections that wrap other collections; those should return the underlying collection's SyncRoot property.

Example

In the absence of a GetSynchronized() method on a collection, the expected usage for SyncRoot would look like this:

ICollection col = ...
synchronized (col->SyncRoot) {
 // Some operation on the collection, which is now thread safe.
}

See Also

ICollection Interface | ICollection Members | System.Collections Namespace | IsSynchronized