/// <summary> /// Disconnect from current channel, closing connection. /// Side effect: channel field is set to null on successful disconnect /// </summary> private void Disconnect() { try { if (connection != null) { Logger.Info("Disconnecting from " + Config.Host + ":" + Config.Port); KafkaConnection temp = connection; connection = null; temp.Dispose(); } } catch (Exception e) { Logger.Error("Error on disconnect: ", e); } }
protected virtual void Dispose(bool disposing) { if (disposing) { if (connection != null) { lock (this) { if (connection != null) { connection.Dispose(); connection = null; } } } } }