How to easy make this counter property thread safe?

前端 未结 5 2326
陌清茗
陌清茗 2021-02-20 08:31

I have property definition in class where i have only Counters, this must be thread-safe and this isn\'t because get and set is not in same lock, How t

5条回答
  •  清酒与你
    2021-02-20 09:28

    You could declare the _DoneCounter variable as "volatile", to make it thread-safe. See this:

    http://msdn.microsoft.com/en-us/library/x13ttww7%28v=vs.71%29.aspx

提交回复
热议问题