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

前端 未结 8 2267

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

    Enter .NET 4.0!

    If you're stuck in 3.5 (or earlier), there are some functions you should look at, like AllocateDataSlot which should do what you want.

提交回复
热议问题