Bonjour, j’arrive pas a arrêter threadPool avec une list proxy.
mon code start & stop :
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
 
Dim cts As New CancellationTokenSource()
 
If Button2.Text = "Start" Then
            If proxyList.Count > 0 Then
                Index = 1
                Dim threads As Integer = NumericUpDown3.Value
                ThreadPool.SetMaxThreads(1, threads)
                For Each proxy In proxyList
                    ThreadPool.QueueUserWorkItem(Sub(s)
                                                     Dim token As CancellationToken = CType(s, CancellationToken)
                                                     If token.IsCancellationRequested Then
                                                         Exit Sub
                                                     Else
                                                         Proxychecker(proxy, token)
                                                     End If
                                                 End Sub, cts.Token)
                Next
                Label14.Text = "0"
                Button2.Text = "Stop"
            End If
        ElseIf Button2.Text = "Stop" Then
            cts.Cancel()
            Button2.Text = "Start"
        End If
Mon code traitement :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
Private Sub Proxychecker(proxy As String, token As CancellationToken)
        While True
            If token.IsCancellationRequested Then
                Exit While
            Else
...etc
End While
        cts.Cancel()
        MsgBox("Traitement Terminer !")
avez-vous une autre solution pour arrêter threadpool ? MERCI DE VOTRE COMPREHENSION...