I dropped a ProgressBar on a form. In the form button_click event, it uses a thread to update the ProgressBar. Please the code below. In the Worker1 class, Console.Write("A") worked but not objForm.ProgressBarMeter1.Value = i which means the ProgressBar did not updated. Any suggestion how the ProgressBar can be updated? Thanks.
Thanks.
DanYeung
VB.NET:
Public Class FormLab11
Private Sub ButtonStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonStart.Click
Dim objWorker1 As New Worker1
Dim objWorker2 As New Worker2
Dim t1 As Thread
Dim t2 As Thread
t1 = New Thread(AddressOf objWorker1.Meter1)
t2 = New Thread(AddressOf objWorker2.Meter2)
t1.Start()
t2.Start()
Do While t1.IsAlive
t2.Join()
Loop
End Sub
End Class
Public Class Worker1
Public Sub Meter1()
Dim objForm As New FormLab11
For i As Integer = 0 To 10000
objForm.ProgressBarMeter1.Value = i
Console.Write("A")
Thread.Sleep(1)
Next
End Sub
End Class
DanYeung
Last edited by a moderator: