private void Dispose(bool byChannel) { if (State == LinkProducerState.Disposed) { return; } lock (_sync) { if (State == LinkProducerState.Disposed) { return; } _logger.Debug($"Disposing ( by channel: {byChannel} )"); _channel.Disposed -= ChannelOnDisposed; if (!byChannel) { _channel.Dispose(); } var ex = new ObjectDisposedException(GetType().Name); _messageQueue.Dispose(); ChangeState(LinkProducerState.Disposed); _readyCompletion.TrySetException(ex); _logger.Debug("Disposed"); _logger.Dispose(); Disposed?.Invoke(this, EventArgs.Empty); } }
public void Dispose() { if (State == LinkConnectionState.Disposed) { return; } lock (_sync) { if (State == LinkConnectionState.Disposed) { return; } _logger.Debug("Disposing"); _disposeCts.Cancel(); _disposeCts.Dispose(); try { _loopTask?.Wait(CancellationToken.None); } catch { // no op } _storage.Dispose(); ChangeState(LinkConnectionState.Disposed); Disposed?.Invoke(this, EventArgs.Empty); _logger.Debug("Disposed"); _logger.Dispose(); } }
private void Dispose(bool byConnection) { if (State == LinkChannelState.Disposed) { return; } lock (_sync) { if (State == LinkChannelState.Disposed) { return; } _logger.Debug($"Disposing ( by connection: {byConnection} )"); _disposeCts.Cancel(); _disposeCts.Dispose(); try { _loopTask?.Wait(CancellationToken.None); } catch { // no op } _connection.Disposed -= ConnectionOnDisposed; ChangeState(LinkChannelState.Disposed); Disposed?.Invoke(this, EventArgs.Empty); _logger.Debug("Disposed"); _logger.Dispose(); } }