Read only Dictionary - multiple threads calling .ContainsKey method Read only Dictionary - multiple threads calling .ContainsKey method multithreading multithreading

Read only Dictionary - multiple threads calling .ContainsKey method


If nobody is mutating it: this is fine. If there were occasional edits, then perhaps look at ReaderWriterLockSlim, or (my preference) edit a snapshot/copy and swap the reference.


if all of the 'adding' is complete before you read from multiple threads then it is fine. Just because its readonly doesnt mean its thread safe - which it isnt.

Maybe you should user ReaderWriterLock to synchronise access