c# – Dictionary<KeyType,ValueType> is it thread safe to read?

Question:

Is Dictionary<KeyType,ValueType> thread safe for reading and Dictionary<KeyType,ValueType> over values?

That is, there will be no entry in this Dictionary (it is initialized only when the project is launched), and I want to understand whether it can be used in the context of a singleton service in ASP.NET Core 2.0?

Answer:

https://msdn.microsoft.com/en-us/library/xfhwa508(v=vs.110).aspx

Thread Safety

A Dictionary can support multiple readers concurrently, as long as the collection is not modified.

that is

Thread safety

… supports multiple concurrent reads as long as the data is not changed.

Scroll to Top