protected override async Task ExecuteAsync(CancellationToken stoppingToken) { try { await _ircClient.ConnectAsync(); _pinger.Start(stoppingToken); // Listen for commands and process them forever while (!stoppingToken.IsCancellationRequested) { try { var message = await _ircClient.ReadMessageAsync(); await HandleReceivedMessageAsync(message); } catch (IOException ioex) { _logger.LogError(ioex, "The following IO exception occurred as a catch-all during command processing."); await HandleReconnectAttemptsAsync(stoppingToken); } catch (Exception ex) { _logger.LogError(ex, "The following exception occurred as a catch-all during command processing."); } } } catch (Exception ex) { _logger.LogError(ex, "The following exception occurred as a catch-all during ExecuteAsync."); } finally { _ircClient.Disconnect(); } }