Domanda

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?)

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top