开发者

Duplicate keys in Dictionary<string,EventHandler>

开发者 https://www.devze.com 2023-01-25 20:53 出处:网络
I have public static readonly Dictionary<string, EventHandler> CacheHandlers = new Dictionary<string, EventHandler>();

I have

public static readonly Dictionary<string, EventHandler> CacheHandlers = new Dictionary<string, EventHandler>();

and I have duplicate keys in this dictionary:

debugger screenshot: http://i.stack.imgur.com/tuXI7.png

How does it happen?

Is it a bug in the .net framework or could it be 开发者_如何学JAVAan artifact of concurent usage?


MSDN states that Dictionarys might not be thread safe.

If you are concurrently reading from the Dictionary, then it might be safe so long as you lock the Dictionary when you add new key/value pairs.

0

精彩评论

暂无评论...
验证码 换一张
取 消