Parallel.ForEachAsync does NOT tolerate exceptions
@@ -233,7 +233,9 @@ public abstract class PoolBase : StratumServer,
protected async Task ForEachMinerAsync(Func<StratumConnection, CancellationToken, Task> func,
Action<Exception> errorHandler, CancellationToken ct)
{
- await Guard(()=> Parallel.ForEachAsync(connections, ct, async (kvp, _ct) =>
+ await Parallel.ForEachAsync(connections, ct, async (kvp, _ct) =>
+ {
+ await Guard(async () =>
{
var con = kvp.Value;
@@ -243,7 +245,8 @@ public abstract class PoolBase : StratumServer,
{
await func(con, _ct);
}
- }), errorHandler);
+ }, errorHandler);
+ });
}
protected bool CloseIfDead(StratumConnection connection, WorkerContextBase context)
