I started to use the new ConcurrentDictionary from .Net4 to implement a simple caching for a threading project.
But I’m wondering what I have to take care of/be careful about when using it?
What have been your experiences using it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Members are thread-safe, but you shouldn’t expect a sequence of calls to be thread-safe. For example you can’t expect the following to be thread-safe:
Instead, use the new thread-safe API – e.g.
AddOrUpdate(last one wins in the event of a race condition) orGetOrAdd(first one wins in the event of a race condition).