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 |
Partager