Beispiel #1
0
        public ConnOfOLE GetOne()
        {
            //if (this.Count == 0)
            //    this.Init();
            while (isLock)
            {
                ;
            }

            isLock = true;
            foreach (ConnOfOLE conn in this)
            {
                if (conn.IsUsing == false)
                {
                    if (conn.Conn == null)
                    {
                        conn.Conn = new OleDbConnection(SystemConfig.AppCenterDSN);
                    }
                    conn.Times++;
                    conn.IsUsing = true;
                    isLock       = false;
                    return(conn);
                }
            }

            // 如果没有新的连接。
            ConnOfOLE nconn = new ConnOfOLE();

            nconn.IDX  = this.Count;
            nconn.Conn = new OleDbConnection(SystemConfig.AppCenterDSN);
            this.InnerList.Add(nconn);
            isLock = false;
            return(nconn);
            //throw new Exception("没有可用的连接了,请报告给管理员。");
        }
Beispiel #2
0
 /// <summary>
 ///  初始化
 /// </summary>
 public void Init()
 {
     for (int i = 0; i <= 1; i++)
     {
         ConnOfOLE conn = new ConnOfOLE();
         conn.IDX = i;
         this.Add(conn);
     }
 }
Beispiel #3
0
 public void Add(ConnOfOLE conn)
 {
     this.InnerList.Add(conn);
 }