" 300 -, - . Application.DoEvents( )".
, Application.DoEvents , x long = 0 long.maxvalue , .
, , , .
Private Sub foo()
stpw.Reset() : stpw.Start()
Do
Loop While stpw.ElapsedMilliseconds < 1000
stpw.Stop()
Debug.WriteLine("foo")
End Sub
Dim stpw As New Stopwatch
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Debug.WriteLine("")
Debug.WriteLine("but click")
Dim t As New Threading.Thread(AddressOf foo)
t.Start()
Do
Threading.Thread.Sleep(10)
'Application.DoEvents() 'uncomment to change the behavior
Loop While stpw.IsRunning
Debug.WriteLine("but exit")
End Sub
So let's say that I originally wrote it without alleging a violation, but the user complained that the user interface was not responding. Therefore, I add DoEvents, but now I get odd results when users double-click on the button. Is the problem DoEvents or just a bad design. I would vote for poor design in this case.
source
share