Is Stopwatch.ElapsedTicks threadsafe?

前端 未结 4 575
野的像风
野的像风 2020-12-20 16:03

If I have a shared System.Diagnostics.Stopwatch instance, can multiple threads call shared.ElapsedTicks in a safe manner and get accurate results?<

4条回答
  •  礼貌的吻别
    2020-12-20 16:49

    Looking at the source code, it is thread-safe, but you must not use: Stop(), Reset() and Restart().

    So, if you start a shared instance, does not modify it and call only ElapsedXXX properties, you should be fine.

提交回复
热议问题