protected override async ValueTask AttemptConnectionsAsync(IConnectionManager connectionManager, CancellationToken cancellation) { foreach (OutgoingConnectionEndPoint remoteEndPoint in connectionsToAttempt) { if (cancellation.IsCancellationRequested) { break; } if (connectionManager.CanConnectTo(remoteEndPoint.EndPoint)) { // note that AttemptConnection is not blocking because it returns when the peer fails to connect or when one of the parties disconnect _ = forgeConnectivity.AttemptConnectionAsync(remoteEndPoint, cancellation).ConfigureAwait(false); // apply a delay between attempts to prevent too many connection attempt in a row await Task.Delay(500, cancellation).ConfigureAwait(false); } } }