public async Task StopAsync() { try { if (_started.TryEnter()) { _completion.TryComplete(); } Log.Debug("Stopping"); _cancellation.Cancel(); foreach (var con in _currentConnections.Keys) { con.Out.TryTerminate(); } await _completion.Task.ConfigureAwait(false); Log.Debug("Stopped"); } catch { // ignore } finally { _stateWriter?.Dispose(); _host?.Dispose(); _host = null; } }
public Task StopAsync() { _log.Debug("Stopping"); // TODO: dispose all the active streams _completion.TryComplete(); _settingsWriter.Dispose(); return(Completion.IgnoreExceptions()); }