If you are about to begin implementing your own version of a thread safe generic weak dictionary – STOP!
As of .NET 4.0, there is already one:
System.Runtime.CompilerServices.ConditionalWeakTable<TKey, TValue>
Now that .NET 4.5 has been made open source few weeks ago, we can look at the comments and more importantly at the implementation of ConditionalWeakTable<TKey, TValue>. Continue reading “Thread Safe Generic Weak Dictionary in .NET”