Possible Duplicate:
Cross-thread operation not valid
Hi, I am testing a background workder. I am running the following code for the test.
Private Sub bgwTest_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgwTest.DoWork
Dim a As Integer = 0
Do While a < 10 'Infinite loop
ComboBox1.Items.Add(1)
Loop
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox1.Visible = True 'Contains my animated GIF
'Purpose is GIF keeps looping (it is animated GIF) despite computer is stuck in infinite loop bgwTest.RunWorkerAsync() End Sub
But this code generates the following error:
"Cross-thread operation not valid: Control 'ComboBox1' accessed from a thread other than the thread it was created on."
Please help. Thanks Furqan