public void Run() { while (!_cancellationTokenSource.IsCancellationRequested) { if (_httpClientSession != null && _webSocketClientSession != null) { throw new InvalidOperationException(); } _httpClientSession?.WaitForRequest(); _webSocketClientSession?.WaitForFrameAsync().Wait(); } }
public async Task RunAsync() { while (!_cancellationTokenSource.IsCancellationRequested) { if (_httpClientSession != null && _webSocketClientSession != null) { throw new InvalidOperationException(); } if (_httpClientSession != null) { await _httpClientSession.WaitForRequestAsync(); } if (_webSocketClientSession != null) { await _webSocketClientSession.WaitForFrameAsync(); } } }