Does C# have a “ThreadLocal” analog (for data members) to the “ThreadStatic” attribute?

前端 未结 8 2256

I\'ve found the \"ThreadStatic\" attribute to be extremely useful recently, but makes me now want a \"ThreadLocal\" type attribute that lets me hav

8条回答
  •  再見小時候
    2020-12-14 09:00

    If you looking to store unique data on a per thread basis you could use Thread.SetData. Be sure to read up on the pros and cons http://msdn.microsoft.com/en-us/library/6sby1byh.aspx as this has performance implications.

提交回复
热议问题