Dispose() public méthode

Close the connection to the server.
public Dispose ( ) : void
Résultat void
        /// <summary>
        /// returns connection back to pool
        /// </summary>
        /// <param name="kafkaConnection"></param>
        public void ReleaseConnection(KafkaConnection kafkaConnection)
        {
            lock (availableConnections)
            {
                if (availableConnections.Count < maxPoolSize &&
                    IsConnectionValid(kafkaConnection))
                {
                    availableConnections.Enqueue(kafkaConnection);
                    return;
                }

                System.Threading.Interlocked.Decrement(ref socketCounter);
                kafkaConnection.Dispose();
            }
        }
        public static void ReleaseConnection(KafkaConnection kafkaConnection)
        {
            Guard.NotNull(kafkaConnection, "kafkaConnection");
            lock (locker)
            {
                string connectionKey = GetConnectionKey(kafkaConnection.Server, kafkaConnection.Port);

                if (kafkaServerConnections.ContainsKey(connectionKey))
                {
                    kafkaServerConnections[connectionKey].ReleaseConnection(kafkaConnection);
                }
                else
                {
                    kafkaConnection.Dispose();
                }
            }
        }
        /// <summary>
        /// Returns an existing or new kafka connection
        /// </summary>
        /// <param name="server">The server to connect to.</param>
        /// <param name="port">The port to connect to.</param>
        /// <param name="bufferSize"></param>
        /// <param name="socketTimeout"></param>
        /// <param name="idleTimeToKeepAlive">idle time until keepalives (ms)</param>
        /// <param name="keepAliveInterval">interval between keepalives(ms)</param>
        /// <param name="socketPollingTimeout">socket polling timeout(usec)</param>
        /// <param name="keepAliveInterval">interval between keepalives(ms)</param>
        public KafkaConnection GetConnection()
        {
            KafkaConnection kafkaConnection = null;

            while (availableConnections.TryDequeue(out kafkaConnection))
            {
                //validate
                if (IsConnectionValid(kafkaConnection))
                {
                    return(kafkaConnection);
                }
                else
                {
                    System.Threading.Interlocked.Decrement(ref socketCounter);
                    kafkaConnection.Dispose();
                }
            }

            return(BuildConnection());
        }