ok j'ai fait une appli à l'aide d'un datagridview comme ceci

Nom : forum.jpg
Affichages : 303
Taille : 178,9 Ko

je veux que chaque ligne soit actualisé au 10-20 seconde

je load le datagrid et je lis chaque ip 1 après l'autre et quand il lit un ip il démarre un nouveau thread de cette façon

Code VB.NET : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
                Dim updatem As System.Threading.Thread
                updatem = New Thread(AddressOf loadTableMiner)
                updatem.Name = Split(texte2, Chr(9))(1)
                updatem.Start()

jusque la tout va bien ... ce que j'ai dans mon loadtableminer c'est une connection ssh comme ceci

Code VB.NET : 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
    Private Sub loadTableMiner()
 
 
        Dim ip As String = Thread.CurrentThread.Name
        Dim clientssh As SshClient
        Dim shellStream As ShellStream
        Dim shellStream2 As ShellStream
 
        Dim outputFrom As String
        Dim ValueSSH As String
        Dim ValueSSHsummary As String
        Try
            clientssh = New SshClient(ip, "root", "admin")
            clientssh.Connect()
            Dim reply As String = String.Empty
            shellStream = clientssh.CreateShellStream("dumb", 80, 24, 800, 600, 1024)
            Dim reader = New StreamReader(shellStream)
 
 
            Do Until InStr(outputFrom, "STATUS=S") > 0 Or InStr(outputFrom, "Connection refused") > 0
                reply = shellStream.Expect(New Regex(":.*>#"), New TimeSpan(0, 0, 1))
 
                shellStream.WriteLine("bmminer-api -o stats")
 
 
                Dim result As String = shellStream.ReadLine(New TimeSpan(0, 0, 1))
                outputFrom = reader.ReadToEnd()
 
 
            Loop
            ValueSSH = outputFrom
            outputFrom = ""
            reader.DiscardBufferedData()
            shellStream.Flush()
 
            shellStream.WriteLine("bmminer-api -o summary")
            Do Until InStr(outputFrom, "STATUS=S") > 0 Or InStr(outputFrom, "Connection refused") > 0
                reply = shellStream.Expect(New Regex(":.*>#"), New TimeSpan(0, 0, 1))
 
                shellStream.WriteLine("bmminer-api -o summary")
 
 
                Dim result As String = shellStream.ReadLine(New TimeSpan(0, 0, 1))
                outputFrom = reader.ReadToEnd
 
 
            Loop
            ValueSSHsummary = Split(outputFrom, ":~# bmminer-api -o summary" & vbCrLf)(1)
            clientssh.Disconnect()
            clientssh.Dispose()
 
        Catch ex As Exception
            clientssh.Disconnect()
            clientssh.Dispose()
 
        End Try
 
 
        Dim items As New ListViewItem
        Dim texte2 As String
        Dim LineRendu As Integer = 0
        Dim F As String = Main.UserDataFolder & "\Wemine4U\Config\MinerList.wemine"
        If IO.File.Exists(F) = True Then
            Dim NOF2 As Integer = FreeFile()
 
 
 
            Dim i As Integer
            FileOpen(NOF2, Main.UserDataFolder & "\Wemine4U\Config\MinerList.wemine", OpenMode.Input, OpenAccess.Read, OpenShare.Shared)
            Dim lineCount = System.IO.File.ReadAllLines(Main.UserDataFolder & "\Wemine4U\Config\MinerList.wemine").Length
 
            Do Until EOF(NOF2)
                texte2 = LineInput(NOF2)
                If Split(texte2, Chr(9))(1) = ip Then
                    FileClose(NOF2)
                    GoTo EndIndexFound
                End If
                LineRendu = LineRendu + 1
 
 
            Loop
        End If
EndIndexFound:
 
 
        If InStr(ValueSSH, "Connection refused") > 0 Then
            DataGridView1.Rows(LineRendu).Cells(9).Value = "Connection refused"
            GoTo repprogress
        End If
 
        If ValueSSH = "" Then
            DataGridView1.Rows(LineRendu).Cells(9).Value = "Not Online"
        Else
 
            If ValueSSHsummary = "" Then
            Else
                Dim Accepteds As String = Split(Split(ValueSSHsummary, "Accepted=")(1).ToString, ",")(0)
                Dim Rejects As String = Split(Split(ValueSSHsummary, "Rejected=")(1).ToString, ",")(0)
                Dim Hwerror As String = Split(Split(ValueSSHsummary, "Hardware Errors=")(1).ToString, ",")(0)
                Dim Discarded As String = Split(Split(ValueSSHsummary, "Discarded=")(1).ToString, ",")(0)
 
                DataGridView1.Rows(LineRendu).Cells(4).Value = Accepteds
                DataGridView1.Rows(LineRendu).Cells(5).Value = Rejects
                DataGridView1.Rows(LineRendu).Cells(6).Value = Discarded
                DataGridView1.Rows(LineRendu).Cells(7).Value = Hwerror
            End If
 
            Dim ValueTemp As String = Split(Split(ValueSSH, ",")(33).ToString, "=")(1)
            Dim NBV As Integer = CountCharacter(ValueSSH, ",")
            Dim nbvt As Integer = 0
            Do Until nbvt = NBV
                Dim TT As String = Split(ValueSSH, ",")(nbvt).ToString
                Dim NBI As Integer = InStr(TT, "temp")
                If NBI > 0 Then
                    Dim tview As String = Split(Split(ValueSSH, ",")(nbvt), "=")(1)
                    If CInt(tview) > CInt(ValueTemp) Then
                        ValueTemp = Split(Split(ValueSSH, ",")(nbvt).ToString, "=")(1)
                    End If
 
                End If
                nbvt = nbvt + 1
            Loop
 
            If 20 > ValueTemp Or ValueTemp > 100 Then
                Dim minerip As String = ip
                Dim SSHCON As New SshClient(ip, "root", "admin")
                Try
 
                    SSHCON.Connect()
                    SSHCON.RunCommand("/sbin/reboot")
                Catch
                    SSHCON.Disconnect()
                    SSHCON.Dispose()
                    GoTo nextminer
                End Try
                SSHCON.Disconnect()
                SSHCON.Dispose()
                DataGridView1.Rows(LineRendu).Cells(1).Value = "0 C"
                DataGridView1.Rows(LineRendu).Cells(2).Value = "0.00"
                DataGridView1.Rows(LineRendu).Cells(3).Value = "0.00"
                DataGridView1.Rows(LineRendu).Cells(9).Value = "Rebooting"
                GoTo nextminer
            End If
            Dim ValueGHS = CDec(Replace(Split(Split(ValueSSH, ",")(14).ToString, "=")(1), ".", ",")) / 1000
            Dim ValueGHSM = CDec(Replace(Split(Split(ValueSSH, ",")(15).ToString, "=")(1), ".", ",")) / 1000
            DataGridView1.Rows(LineRendu).Cells(1).Value = ValueTemp + " C"
            DataGridView1.Rows(LineRendu).Cells(2).Value = Format(ValueGHS, "0.00")
            DataGridView1.Rows(LineRendu).Cells(3).Value = Format(ValueGHSM, "0.00")
            If ValueGHS > 0 Then
                DataGridView1.Rows(LineRendu).Cells(9).Value = "Mining"
            Else
                DataGridView1.Rows(LineRendu).Cells(9).Value = "Problems"
            End If
            Dim ValueGHSDIFF As Decimal = ValueGHSM - ValueGHS
            Dim ValueReboot As Decimal = "0,5"
            If ValueGHSDIFF > ValueReboot Then
                Dim minerip As String = ip
                Dim SSHCON As New SshClient(ip, "root", "admin")
                Try
 
                    SSHCON.Connect()
                    SSHCON.RunCommand("/sbin/reboot")
                Catch
                    SSHCON.Disconnect()
                    SSHCON.Dispose()
                    GoTo nextminer
                End Try
                SSHCON.Disconnect()
                SSHCON.Dispose()
                DataGridView1.Rows(LineRendu).Cells(1).Value = "0 C"
                DataGridView1.Rows(LineRendu).Cells(2).Value = "0.00"
                DataGridView1.Rows(LineRendu).Cells(3).Value = "0.00"
                DataGridView1.Rows(LineRendu).Cells(9).Value = "Rebooting"
                GoTo nextminer
            End If
 
            Dim G As Integer = 0
            If InStr(texte2, "S9") > 1 Then
                DataGridView1.Rows(LineRendu).Cells(10).Value = "S9"
                G = 0
            End If
            If InStr(texte2, "Z9") > 1 Then
                G = 1
            End If
 
        End If
 
repprogress:
 
nextminer:
 
 
        Dim updatem As System.Threading.Thread
        updatem = New Thread(AddressOf loadTableMiner)
        updatem.Name = Thread.CurrentThread.Name
        updatem.Start()
  Thread.CurrentThread.Abort()
    End Sub

en gros tout fonctionne mais pas comme je le souhaite je m'Explique ... premièrement ça prend 5 bonnes minutes avant que toutes les donnes du datagridview soient mises à jour.... et ensuite une fois le datagridview rempli... chaque ligne du datagrisview prend au moins 2,3 minutes avant de se reupdater ... je suis loin de mon 10,20 secondes de refresh par ligne... mon datagrid contient environ 200 éléments (lignes) où est mon erreur de codage ? J'aurais dû utiliser un backgroundworker ? Des timers ? Je cherche une piste bref