To workaround it, there is one method in window forms called:
Application.DoEvents()
which you want to call periodically.
for example:
Code Snippet
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Enabled = False
ProgressBar1.Show()
ProgressBar1.Value = 0
ProgressBar1.Maximum = 10
Cursor = Cursors.WaitCursor
Try
For x As Int32 = 1 To 10
Application.DoEvents()
DoSomething()
Next
Finally
ProgressBar1.Hide()
Button1.Enabled = True
Cursor = Cursors.Default
End Try
End Sub
Public Sub DoSomething()
Dim d As Date = Now
Do While d.AddSeconds(1) > Now
'This is just to fill time.
Loop
ProgressBar1.Value += 1
End Sub
No comments:
Post a Comment