Timer (System.Threading) thread safety

后端 未结 2 702
离开以前
离开以前 2021-01-23 00:24

Does anyone know if this code would be thread safe, or do I have to use lock when calling timer2.Change?

Timer timer1 = new Timer(timerCallback1);
Timer timer2 =         


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-23 00:33

    Per MSDN documentation the Timer type is thread safe, so the only place you have to be careful is where you call DoStuff();.

提交回复
热议问题