protected override async Task DelayAsync(CancellationToken token) { var status = BinanceStatus.Normal; try { status = await _api.GetSystemStatusAsync(token) .ConfigureAwait(false); } catch { /* ignored */ } if (status == BinanceStatus.Normal) { await base.DelayAsync(token) .ConfigureAwait(false); return; } while (status == BinanceStatus.Maintenance) { await Task.Delay(SystemMaintenanceCheckDelayMilliseconds, token) .ConfigureAwait(false); try { status = await _api.GetSystemStatusAsync(token) .ConfigureAwait(false); } catch { /* ignored */ } } }
protected override async Task DelayAsync(CancellationToken token) { var status = BinanceStatus.Normal; try { status = await _api.GetSystemStatusAsync(token) .ConfigureAwait(false); } catch { /* ignore */ } Logger?.LogDebug($"{nameof(BinanceWebSocketStreamController)}: System status ({status}). [thread: {Thread.CurrentThread.ManagedThreadId}]"); if (status == BinanceStatus.Normal) { await base.DelayAsync(token) .ConfigureAwait(false); return; } while (status == BinanceStatus.Maintenance) { // Notify listeners. OnPausing(TimeSpan.FromMilliseconds(SystemMaintenanceCheckDelayMilliseconds)); Logger?.LogDebug($"{nameof(BinanceWebSocketStreamController)}: Delaying for {SystemMaintenanceCheckDelayMilliseconds} msec. [thread: {Thread.CurrentThread.ManagedThreadId}]"); await Task.Delay(SystemMaintenanceCheckDelayMilliseconds, token) .ConfigureAwait(false); try { status = await _api.GetSystemStatusAsync(token) .ConfigureAwait(false); } catch { /* ignore */ } } }