Bonsoir,
Je débute dans l'utilisation des backgroundworker et j'ai un soucis,
mon backgroundworker charge des données dans une datagridview pour que le chargement soit fluide et synchronisé,
pour ceci j'ai triché en utilisant
pour autoriser un thread à accéder a un autre,
Code : Sélectionner tout - Visualiser dans une fenêtre à part Control.CheckForIllegalCrossThreadCalls = False
Mon soucis est le suivant, une fois les données chargés l'interface ne répond plus, j'ai essayé de faire dispose pour libérer les ressource ou j'ai mis une msgbox pour voir si je terminais bien ma boucle et je la termine mais après plus rien
Donc je cherche une solution pour pouvoir attacher ma datagridview a mon backgroundworker ou sinon a ce que ma fenetre ne se freeze plus
mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork Dim j As Integer MsgBox(finfin) For j = debut.Text To finfin - 1 'Threading.Thread.Sleep(50) Try My.Computer.Network.DownloadFile(chaine & j & TextBox2.Text, My.Application.Info.DirectoryPath & "temp/Data" & j & ".txt") Dim Flux As New StreamReader(My.Application.Info.DirectoryPath & "temp/Data" & j & ".txt", False) Dim resultat As String = Flux.ReadToEnd Flux.Close() Dim index1, index2 As Integer index1 = resultat.IndexOf("<leet>", 0) index2 = resultat.IndexOf("</leet>", index1 + 1) DGVdata.Rows.Add(resultat.Substring(index1 + 6, index2 - index1 - 6)) File.Delete(My.Application.Info.DirectoryPath & "temp/Data" & j & ".txt") Catch ex As Exception 'MsgBox(ex.ToString) DGVdata.Rows.Add("Impossible") End Try Next MsgBox("fini") End sub
Partager