I know ReadOnlyDictionary
is "thread-safe" when accessing from multiple threads as long as the collection isn't changing.
But what if the collection isn't changing (no keys are ever added/removed) and values are thread-safe by themselves, meaning, the reference will not change, but the value's internal data might (the Value
object itself is thread safe)
For example
ReadOnlyDictionary<Key, ThreadSafe Value> dictionary = new...
dictionary[key].inc()
Where inc()
is a thread safe method of ThreadSafeValue
.
Since the collection itself isn't changing, and the references aren't changing, I'd think this is ok, but since ReadOnlyDictionary doesn't expose Add/Remove/Update and it's not thread safe, I wonder if my assumption is correct