Thread Safety for collections

J

Jack

How does dotnet handles thread safety of Collections ?

I derived some classes from CollectionBase and DictionaryBase, and created
some typed Add, Remove methods to call typeless based Add, Remove methods.
Do I have to handle the locking myself ?

If one thread gets the IEnumerator, and iterate it. What happens when
another thread wanna add things to the collection ?

Thanks
Jack
 
J

Jack

I got it from MSDN. Only type operations are thread safe, and instance
operations are not thread safe. We have to synchronize the calls ourselves.

However, I've another question:
What's the differece between using Hashtable or implementing collections
based on DictionaryBase, in terms of performance and memory usage?
I need a collection class that can some itmes, say 10000 but should retrive
fast with its key.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top