在 Timer.Tick 中调用停止计时器

Calling Stop Timer in Timer.Tick

我在myTimer_Tick方法中间调用了myTimer.Stop();。在问这个问题之前,我看了这个问题:Stop timer in the middle of the tick;但我的问题有些不同:

我认为如果调用myTimer.Stop()myTimer.Enable = false,Tick方法将运行结束但不会有下一个Tick。事实上,我不想立即停止 Tick 方法和 return。

我说得对吗?

编辑: 我尝试在示例中展示我想要的内容:

void mytimer_Tick(object sender, EventArgs e)
{
    someWorks1;
    myTimer.Stop();
    someWorks2;
}

我也想要最后一次someWorks2运行

I think if call myTimer.Stop() or myTimer.Enable = false, the Tick method will run to the end but there won't be the next Tick.

正确。停止计时器将不会 终止执行回调函数的线程。您的 Tick 方法将继续 运行 直到它 returns.

您可以轻松编写示例来证明这一点。