public void ReleaseConnection(CrmConnection connection)
        {
            if (connection == null)
            {
                return;
            }

            lock (_syncLock)
            {
                if (connection.HasError)
                {
                    RemoveConnectionsFromConnections(connection);
                    Logger.Debug($"CrmConnectionPool.ReleaseConnection Removed due to error: {connection.ErrorMessage}.");
                }
                else
                {
                    _stack.Push(connection);
                }

                Logger.Debug($"CrmConnectionPool.ReleaseConnection Connections: {_connections.Count} Queue: {_stack.Count}.");
            }
        }
Пример #2
0
 public CrmConnection Connect()
 {
     return(_connection = _pool.ReserveConnection());
 }
 private int RemoveConnectionsFromConnections(CrmConnection connection)
 {
     _connections.Remove(connection);
     connection.Dispose();
     return(_connections.Count);
 }