I discovered 'ThreadStaticAttribute', and I have a lot of questions about it: all my previous thread dependent static informations, were implemented as a static dictionary wich TKey is Thread, and when I wanted to access it, I used Thread.CurrentThread and that works. But this requires mantainance, because if a thread dies, I have to delete the corresponding entry from the dictionary. And I also need to consider thread-safety, and a lot of other matters.
By using ThreadStaticAttribute, all these matters seems to be solved, but I need to be sure of it. My questions are: do I need to delete the instance hold by 'ThreadStaticAttribute' marked fields, somehow, before the thread dies?? Where is the information of that field hold?? It is in the instance of Thread object, or something like that, so that when it is not used anymore, garbage collector automatically discards it? Are there performance penalties? What ones? Is it faster than using a Keyed collection like I was doing?
Please, I need clarification on how 'ThreadStaticAttribute' work.
Thanks.