Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int num = Convert.ToInt32(txbNum1.Text);
            int rep = Convert.ToInt32(txbRep1.Text);
            
            
            this.button1.Text = "Working";
            this.button1.Enabled = false;
            ThreadStart start2 = () =>
            {
                double[] r = new double[rep];
                for (int k = 0; k < rep; k++)
                {
                    var oo = new OilDataAccess();
                    DateTime dt = DateTime.Now;
                    var a = oo.Get("1=1", num, " id desc");
                    r[k] = (DateTime.Now - dt).TotalMilliseconds;
                }

                for (int k = 0; k < rep; k++)
                {
                    this.richTextBox1.AppendText(string.Format("读取 {0} 条, 第 {2} 次花费 {1} ms \n", num, r[k], k + 1));
                }
                this.button1.Text = "Run";
                this.button1.Enabled = true;
                this.richTextBox1.AppendText("\n");
            };
            this.Invoke(start2);
        }