private MQSession GetSessionFromNewConnection(MQChannelDefinition mqcd, MQSSLConfigOptions sslConfigOptions, MQConnectionSecurityParameters mqcsp, MQFAP fap, string qMgrName, int connectOptions, int maxFapLevel)
        {
            uint method = 0x599;

            this.TrEntry(method, new object[] { mqcsp, fap, qMgrName, connectOptions, maxFapLevel });
            MQFAPConnection connection = null;
            MQSession       session    = null;

            try
            {
                this.connectionsLock.Acquire();
                connection = this.CreateAndConnectConnection(mqcd, sslConfigOptions, mqcsp, fap, qMgrName, connectOptions, maxFapLevel);
                session    = connection.AssignSession();
                session.ParentConnection = connection;
                session.InitSendReceiveExits(true);
                if (connection.GetFreeConversations() > 0)
                {
                    this.AddConnection(connection);
                }
            }
            finally
            {
                this.connectionsLock.Release();
                base.TrExit(method);
            }
            return(session);
        }
        private MQSession GetSessionFromEligibleConnection()
        {
            uint method = 0x59b;

            this.TrEntry(method);
            MQSession session = null;
            bool      flag    = true;

            try
            {
                this.connectionsLock.Acquire();
                if (this.eligibleConnections.Count != 0)
                {
                    MQFAPConnection connection = (MQFAPConnection)this.eligibleConnections[0];
                    if (connection.GetFreeConversations() == 1)
                    {
                        this.RemoveConnection(connection);
                    }
                    if (connection.IsReconnectRequested)
                    {
                        this.RemoveConnection(connection);
                        base.TrExit(method, null, 1);
                        return(null);
                    }
                    if (!connection.IsConnected)
                    {
                        this.RemoveConnection(connection);
                        base.TrExit(method, null, 2);
                        return(null);
                    }
                    session = connection.AssignSession();
                    session.InitSendReceiveExits(false);
                    session.StartConversation();
                    flag = false;
                }
                else if (this.connectingConnections > 0)
                {
                    try
                    {
                        flag = false;
                        this.connectionsLock.Wait();
                    }
                    catch (ThreadInterruptedException exception)
                    {
                        base.TrException(method, exception);
                    }
                }
                if (flag)
                {
                    Thread.Sleep(0);
                }
            }
            finally
            {
                this.connectionsLock.Release();
                base.TrExit(method, 3);
            }
            return(session);
        }