comment arreter avec Parallel.ForEach
Bonjour,
je suis bloqué pour arrêter Parallel.ForEach avec CancellationTokenSource, pouvez-m'aider a résoudre mon problème pour arrêter !
voici mon code :
Code:
1 2 3 4 5 6 7 8 9 10
| 'START
task.Factory.StartNew(Sub()
While Not cts.IsCancellationRequested
Parallel.ForEach(ListProxy, New ParallelOptions With {.MaxDegreeOfParallelism = Threads_1, .CancellationToken = cts.Token}, Sub(adress As String)
'Mon code lire proxy End Sub)
End While
End Sub, cts.Token)
'Button 2
cts.Cancel() |
avez-vous une autre solution pour arrêter avec Parallel.ForEach?