ConcurrentKeyedCollection approach

1.1k views Asked by At

Id like to make use of a ConcurrentKeyedCollection - but it doesn't exist.
Why no ConcurrentKeyedCollection?
What should I be using? (ConcurrentDictionary? Wrap my own concurrency protection around a KeyedCollection?)

1

There are 1 answers

1
Ricibob On BEST ANSWER

SynchronizedKeyedCollection introduced in .NET 2.0 does the job - using a List and wrapping access in a lock. Note that the newer "Concurrent" collections introduced in .NET 4.0 used an improved mechanism and should scale better - but they dont offer a KeyedCollection. More info on "Synchronized" vs "Concurrent" collections here.