Exemple #1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            int    MinConnection      = Convert.ToInt16(txtMinConn.Text);
            int    MaxConnection      = Convert.ToInt16(txtMaxConn.Text);
            int    SeepConnection     = Convert.ToInt16(txtNewConn.Text);
            int    KeepRealConnection = Convert.ToInt16(txtKeepRealConnection.Text);
            string ConnectionString   = txtConnectionString.Text;

            c = new ConnPool(ConnectionString, ConnTypeEnum.MySqlClient, MaxConnection, MinConnection, SeepConnection, KeepRealConnection);
            c.MaxRepeatDegree = Convert.ToInt16(txtMaxRepeatDegree.Text);
            c.Interval        = 1;
            c.ExistMinute     = Convert.ToInt16(txtExistTime.Text);
            c.StartServices();
            checkPoolThread.Interrupt();
            txtMinConn.ReadOnly            = true;
            txtMaxConn.ReadOnly            = true;
            txtNewConn.ReadOnly            = true;
            txtKeepRealConnection.ReadOnly = true;
            txtConnectionString.ReadOnly   = true;
            txtMaxRepeatDegree.ReadOnly    = true;
            txtExistTime.ReadOnly          = true;
            btnGetConn.Enabled             = true;
            btnDisConn.Enabled             = true;
            btnStart.Enabled = false;
        }
Exemple #2
0
        private string print(ConnPool c)
        {
            StringBuilder sb = new StringBuilder();

            //Console.WriteLine("最大可以创建的连接数目:" + c.MaxConnection.ToString());
            //Console.WriteLine("每个连接的最大引用记数:" + c.MaxRepeatDegree.ToString());
            //Console.WriteLine("保留的实际空闲连接:" + c.KeepRealConnection.ToString());
            sb.AppendLine("实际连接(包含失效的):" + c.RealFormPool.ToString());
            sb.AppendLine("实际连接(不包含失效的):" + c.PotentRealFormPool.ToString());
            sb.AppendLine("目前可以提供的连接数:" + c.SpareFormPool.ToString());
            sb.AppendLine("空闲的实际连接:" + c.SpareRealFormPool.ToString());
            sb.AppendLine("已分配的实际连接:" + c.UseRealFormPool.ToString());
            sb.AppendLine("已分配连接数:" + c.UseFormPool.ToString());
            sb.AppendLine("已分配只读连接:" + c.ReadOnlyFormPool.ToString());
            sb.AppendLine("--------------------------");
            return(sb.ToString());
        }