线程独享的数据,可以通过Thread类的静态方法SetData和GetData方法实现,也可以通过静态变量加上[ThreadStatic]特性。

Msdn推荐优先使用ThreadStatic修饰静态字段的方法,只有在数据的类型无法确定时再使用数据槽LocalDataStoreSlot和SetData,GetData方法。后者在性能上不如前者,而且使用复杂。

相关文章:

  • 2022-02-16
  • 2021-05-23
  • 2021-09-11
  • 2022-01-15
  • 2022-02-12
  • 2021-06-30
  • 2021-12-21
猜你喜欢
  • 2021-07-17
  • 2021-10-12
  • 2021-09-28
  • 2022-12-23
  • 2022-01-15
  • 2021-04-18
  • 2021-06-22
相关资源
相似解决方案