The MSDN documentation of System.Collections.Concurrent.ConcurrentDictionary says:
Thread Safety
All public and protected members of
ConcurrentDictionary<TKey, TValue>
are thread-safe and may be used concurrently from multiple threads. However, members accessed through one of the interfaces theConcurrentDictionary<TKey, TValue>
implements, including extension methods, are not guaranteed to be thread safe and may need to be synchronized by the caller.
(emphasis mine)
This seems self-contradictory. "All members are thread-safe. But members [sometimes] are not thread-safe."
I do understand that extension methods are of course not guaranteed to be thread safe.
But what do they mean by "accessed through one of the interfaces"? Is TryGetValue
(a member of the IDictionary<TKey, TValue>
interface) thread-safe?