I'm using a readonly dictionary object in a class instantiated with a Singleton lifestyle in an ASP.NET. There's no locking around access to the dictionary object.
Would you expect there to be any .NET contention around reading from this object, given that there may be many web requests accessing it at the same time
CodePudding user response:
This question is actually about dictionary thread-safety, Windsor is unrelated.
Assuming you're using the standard .NET collections,
the MSDN docs for System.Collections.Generic.Dictionary<K,V>
say:
A Dictionary(TKey, TValue) can support multiple readers concurrently, as long as the collection is not modified.
But it's not thread-safe if you have concurrent writers, which means that it probably doesn't lock anything internally, so I wouldn't expect any contention.
CodePudding user response:
What version of Castle Windsor do you use ? Its a bug in 3.2 version - https://github.com/castleproject/Windsor/issues/34
Just upgrade version