Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的代码中,我有一个方法MyMethod()会定期从外部调用(通常约 6 秒)。
MyMethod()
但在某些情况下,我的方法将不再被调用(例如,用户取消了进度)并且我没有可能检查此事件。
由于这个事实,我想启动一个 10 秒的计时器,当我的方法在这个时间范围内没有被调用时,它将被触发。
我如何以及何时可以启动此计时器?
myTimer.Stop()
myTimer.Start()
每次你点击你的方法时,计时器将被重置,如果在十秒内没有再次调用该方法,你的计时器将被触发。