简体   繁体   English

前一个过去的事件结束后仅触发计时器事件吗? [C#]

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

仅在上一个Elapsed事件结束后才可以触发System.Timers.Timer.Elapsed吗?

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. 这样可以保证您只能处理一次处理程序。

Timer.Interval属性可能对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM