Reputation: 5403
How do you break the execution of a Parallel.ForEach()
loop at a timeout interval?
I have tried the CancelizationTokenSource but that cancels the entire ForEach. I just want the one task to cancel, not the entire loop.
Upvotes: 1
Views: 2124
Reputation: 71573
You'd have to set up the task to be performed by Parallel.ForEach with its own timeout mechanism, which would end the task thread without performing the operation, but also without telling Parallel.ForEach that there's a problem big enough for it to terminate the entire operation.
Upvotes: 3