예제 #1
0
        public DbCommon GetDbCommon()
        {
            if (this.dbCommonQueue.TryDequeue(out DbCommon _dbCommon))
            {
                return(_dbCommon);
            }

            DbCommon _dbCommonNew = new DbCommon(this.dbHost, this.dbPort, this.dbUser, this.dbPass, this.dbName);

            _dbCommonNew.Open();
            return(_dbCommonNew);
        }
예제 #2
0
 private void StartThread()
 {
     while (this.running)
     {
         if (this.dbCommonQueue.Count >= this.size)
         {
             Thread.Sleep(1);
         }
         while (this.dbCommonQueue.Count < this.size)
         {
             try
             {
                 DbCommon _dbCommon = new DbCommon(this.dbHost, this.dbPort, this.dbUser, this.dbPass, this.dbName);
                 _dbCommon.Open();
                 this.dbCommonQueue.Enqueue(_dbCommon);
             }
             catch
             {
                 this.LogAction("Can not open db connection.");
             }
         }
     }
 }