【发布时间】:2015-03-04 16:43:20
【问题描述】:
我使用这个代码:-
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If button.Location.Y >= 618 Then
MessageBox.Show("You lost!", "Failure", MessageBoxButtons.RetryCancel)
Timer1.Enabled = False
End If
End Sub
让我们假设条件始终为真,而不是禁用 timer1,而是无限次显示消息框。但是如果我先写 Timer.enable = false 然后再写消息框,则计时器停止。为什么会发生这种情况
【问题讨论】:
-
当你显示一个带有show的消息框时,它后面的代码在消息框关闭之前不会执行。 Time1.Enabled = False 只有在消息框关闭后才会执行。
-
“被告”姓名为:Application.DoEvents 相关:What is a message pump?