Exemplo n.º 1
0
 private void 实时信息显示方法(实时信息 msg)
 {
     label3.Text = msg.sum.ToString();
     label4.Text = msg.current.ToString();
 }
Exemplo n.º 2
0
        public void runMethod()
        {
            int cont = 100000;      //执行多少次
            threadStartEvent.Invoke(100, new EventArgs());//通知主界面,我开始了,count用来设置进度条的最大值
            double t1 = 0, t2 = 0;
            int jindu = 0, temp = 0;
            实时信息 msg = new 实时信息();
            for (int i = 0; i < cont; i++)
            {
                msg.current = i + 1;
                msg.sum = cont;
                thread实时信息.Invoke(msg, new EventArgs());
                t1 = i;
                t2 = cont;
                if (t1 > 0)
                {
                    jindu = (int)(t1 / t2 * 100);
                }
                if (jindu == temp + 1)
                {
                    threadEvent.Invoke(jindu, new EventArgs());//通知主界面我正在执行,i表示进度条当前进度
                    Thread.Sleep(100);//休息100毫秒,模拟执行大数据量操作
                    temp = jindu;
                }

            }
            threadEndEvent.Invoke(new object(), new EventArgs());//通知主界面我已经完成了
        }