You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current Parallel.ForEach passes a loop state to any method calls. This can be valuable as any break may necessitate immediate stoppage of the loop, which can be done by calling loopstate.Stop().
The text was updated successfully, but these errors were encountered:
I would challenge you with such feature request and ask to think about using CancellationToken which is the recommended thing to use with asynchronous operations. Here is an example:
publicIAsyncEnumerableEnumerate()=>newAsyncEnumerable(asyncyield=>{varresult1=awaitFooAsync(yield.CancellationToken);awaityield.ReturnAsync(result1);varresult2=awaitBarAsync(yield.CancellationToken);awaityield.ReturnAsync(result2);});publicasyncTaskProcessAsync(CancellationTokencancellationToken){varinnerCts=newCancellationTokenSource();varcombinedCancellationToken=CancellationTokenSource.CreateLinkedTokenSource(cancellationToken,innerCts.Token);awaitEnumerate().ForEachAsync(async item =>{if(...)// cancellation-control logicinnerCts.Cancel();// cancels all associated async tasks and ForEachAsync // will throw OperationCanceledException},cancellationToken:combinedCancellationToken);}
Current Parallel.ForEach passes a loop state to any method calls. This can be valuable as any break may necessitate immediate stoppage of the loop, which can be done by calling loopstate.Stop().
The text was updated successfully, but these errors were encountered: