How do I gracefully stop a System.Threading.Timer?

后端 未结 4 801
星月不相逢
星月不相逢 2021-02-13 03:57

I have a Windows Service implemented in C# that needs to do some work every so often. I\'ve implemented this using a System.Threading.Timer with a callback method t

4条回答
  •  一个人的身影
    2021-02-13 04:56

    You do not need to dispose of the timer to stop it. You can call Timer.Stop() or set Timer.Enabled to false, either of which will stop the timer from running.

提交回复
热议问题