c# – Dictionary<KeyType,ValueType> is it thread safe for reading?

Question:

Is Dictionary<KeyType,ValueType> thread-safe for reading and iterating 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 doesn't change.

Scroll to Top