You can, but you will also need to synchronize (because Dictionary<,>it is not thread safe).
Alternative:
Of course, one of the advantages of using a dictionary compared to ThreadStaticAttibutethat is that you do not need to worry about garbage, not black magic. If you are using .NET 4 ThreadLocal<T>, perhaps the best option.
source
share