Synchronizing a Timers.Timer elapsed method when stopping

后端 未结 5 1512
情书的邮戳
情书的邮戳 2020-12-19 09:18

With reference to this quote from MSDN about the System.Timers.Timer:

The Timer.Elapsed event is raised on a ThreadPool thread, so the event-handl

5条回答
  •  抹茶落季
    2020-12-19 09:40

    Seems timer is not thread safe. You must keep all calls to it in sync via locking. lock(object){} is actually just short hand for a simple monitor call.

提交回复
热议问题