Only fire Timer event after previous Elapsed event has finished? [c#]

折月煮酒 提交于 2019-12-20 05:47:24

问题


Is there way to fire the System.Timers.Timer.Elapsed only after the previous Elapsed event has finished?


回答1:


A common pattern to avoid this.

  • Start the timer
  • Stop it in the beginning of the handler
  • Start it again at the end of the handler

This guarantees you can only ever be processing the handler once.




回答2:


The Timer.Interval property may be helpful for you.



来源:https://stackoverflow.com/questions/5683073/only-fire-timer-event-after-previous-elapsed-event-has-finished-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!