G
Guest
I grabbed a snippet from here:
http://www.tek-tips.com/pops/emailfaq.cfm?pid=0&fid=5929
I slightly modify:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim tCounter As New Thread(AddressOf RunCounter)
tCounter.Start()
End Sub
Private Sub RunCounter()
Dim Counter As Integer
Me.ProgressBar1.Maximum = 1000
Do
Me.Label1.Text = Counter & "/" & 1000
Me.ProgressBar1.Value = Counter
Counter += 1
Loop While Counter < 1000
MsgBox("job is done " & ProgressBar1.Maximum)
End Sub
Here's the run-tim error I get:
Cross-thread operation not valid: Control 'ProgressBar1' accessed from a
thread other than the thread it was created on.
Appreciate any advise...?
thx in advance
http://www.tek-tips.com/pops/emailfaq.cfm?pid=0&fid=5929
I slightly modify:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim tCounter As New Thread(AddressOf RunCounter)
tCounter.Start()
End Sub
Private Sub RunCounter()
Dim Counter As Integer
Me.ProgressBar1.Maximum = 1000
Do
Me.Label1.Text = Counter & "/" & 1000
Me.ProgressBar1.Value = Counter
Counter += 1
Loop While Counter < 1000
MsgBox("job is done " & ProgressBar1.Maximum)
End Sub
Here's the run-tim error I get:
Cross-thread operation not valid: Control 'ProgressBar1' accessed from a
thread other than the thread it was created on.
Appreciate any advise...?
thx in advance