Stò facendo un programma che utilizza un background worker per poter fare un download da ftp in asincrono. Dato che la progress bar del vb non mi piace per niente, mi sono creato io personalmente una progress bar grafica con delle pictureBox. La domanda ora è: come faccio a modificare le proprietà della pictureBox tramite il background worker? vi posto la parte di codice e il log errore:
Private Sub bgwConnect_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgwConnect.DoWork
Dim t As New Threading.Thread(AddressOf DownloadDB) 'Dowload file from FTP
Dim t2 As New Threading.Thread(AddressOf DropAdvancing) 'Avanzamento progressbar
t.Start()
t2.Start()
While t.IsAlive
'Stuff
End While
t2.Abort()
End Sub
Public Sub DropAdvancing()
Do
pct1.Visible = False
pct2.Visible = False
pct3.Visible = False
System.Threading.Thread.Sleep(100)
pct1.Visible = True
System.Threading.Thread.Sleep(100)
pct2.Visible = True
System.Threading.Thread.Sleep(100)
pct3.Visible = True
Loop
End Sub
log errore:
Cross-thread operation not valid: Control 'pct1' accessed from a thread other than the thread it was created on.
Grazie mille!