Hashtable to Dictionary<> syncroot .

前端 未结 4 1172
闹比i
闹比i 2020-12-03 14:45

Hashtables have a syncroot property but generic dictionaries don\'t. If I have code that does this:

lock (hashtable.Syncroot)
{
....
}

How

4条回答
  •  既然无缘
    2020-12-03 15:23

    var dictionary = new Dictionary();
    
    lock(((ICollection) dictionary).SyncRoot)
    {
        // ...
    }
    

提交回复
热议问题