Hashtables have a syncroot property but generic dictionaries don\'t. If I have code that does this:
lock (hashtable.Syncroot)
{
....
}
How
The new thinking behind SyncRoot is that it was a mistake in the original design. If the only thing to lock is the dictionary and it's private, you can lock it or another object that serves as the synchronization object. The latter technique is useful when the state you are protecting is more than just the dictionary.
// used as you would have used SyncRoot before
object _syncLock = new object();
Dictionary numberMapper = new Dictionary();
// in some method...
lock (_syncLock)
{
// use the dictionary here.
}