Esempio n. 1
0
        public void BackConnection(PDBConnection conn, bool isErr)
        {
            if (!isErr && conn.IsValid())
            {
                lock (this)
                {
                    connList_.Add(conn);
                }
            }
            else
            {
                conn.Dispose();
                Interlocked.Decrement(ref curConnCnt_);
            }

            connEvent_.Set();
        }
Esempio n. 2
0
        public PDBConnection GetConnection()
        {
            do
            {
                lock (this)
                {
                    while (connList_.Count > 0)
                    {
                        int           idx     = connList_.Count - 1;
                        PDBConnection tmpConn = connList_[idx];
                        connList_.RemoveAt(idx);

                        if (tmpConn.IsValid())
                        {
                            return(tmpConn);
                        }
                        else
                        {
                            tmpConn.Dispose();
                            Interlocked.Decrement(ref curConnCnt_);
                            connEvent_.Set();
                        }
                    }

                    if (curConnCnt_ < maxConnCnt_)
                    {
                        PDBConnection conn = new PDBConnection(connStr_);
                        conn.Open();
                        Interlocked.Increment(ref curConnCnt_);
                        return(conn);
                    }
                    else
                    {
                        connEvent_.Reset();
                    }
                }

                connEvent_.WaitOne();
            } while (true);
        }
Esempio n. 3
0
        /// <summary>
        /// Open database with connectstring
        /// </summary>
        public void Open()
        {
            if (conn != null && conn.IsValid() == true)
            {
                ;
            }

            conn = new PDBConnection(ConnectString);
            conn.Open();
        }