Utiliser les threads et picturebox
Bonjour,
J'essaye de rafraichir une gif sur une form, pendant un traitement assez lourd.
Pas de soucis je créé un thread différent, dans lequel je vais lancer l'affichage de mon gif.
Problème, c'est qu'il me sort cette erreur
Citation:
Le contrôle 'PictureBox26' a fait l'objet d'un accès à partir d'un thread autre que celui sur lequel il a été créé.
J'ai lu des choses sur invoke etc... Mais j'ai l'impression d'être un gamin de 8ans, j'arrive pas à comprendre.
Voici mon code:
Code:
1 2 3 4 5
| Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
Cursor.Current = Cursors.WaitCursor
test_fin_process = 0
BackgroundWorker.RunWorkerAsync()
... |
Code:
1 2 3 4 5 6
| Private Sub BackgroundWorker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker.DoWork
While test_fin_process = 0
PictureBox26.Show()
System.Windows.Forms.Application.DoEvents()
End While
End Sub |
Code:
1 2 3 4
| Private Sub BackgroundWorker_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker.RunWorkerCompleted
PictureBox26.Hide()
System.Windows.Forms.Application.DoEvents()
End Sub |
Si vous pouvez m'aiguiller... Merci