/// <summary> /// Performs application-defined tasks associated with freeing, /// releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { if (_channel != null) { _channel.CloseConnection(); } GC.SuppressFinalize(this); }
/// <summary> /// 'IDisposable' implementation. /// </summary> /// <param name="disposeManaged">Whether to dispose managed resources.</param> protected virtual void Dispose(bool disposeManaged) { // Return if already disposed. if (this._alreadyDisposed) { return; } // Release managed resources if needed. if (disposeManaged) { this.Consumer?.Dispose(); this.Producer?.Dispose(); this._channel?.Dispose(); ChannelFactory.CloseConnection(); } this._alreadyDisposed = true; }