进度条

  private void button3_Click(object sender, EventArgs e)
        {

            Thread thread = new Thread(new ThreadStart(Send)); //模拟进度条
            thread.IsBackground = true;
            thread.Start(); 
        }
        private void Send()
        {
            int i = 0;
            while (i <= 100)
            {
                //显示进度 信息
                this.ShowPro(i);
                //循环发生文件
                //模拟的
                i++;
                //模拟发送多少
                Thread.Sleep(100);
            }
            Thread.CurrentThread.Abort();
        }

        private delegate void ProgressBarShow(int i);

        private void ShowPro(int value)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new ProgressBarShow(ShowPro), value);
            }
            else
            {
                this.progressBar1.Value = value; this.label1.Text = value + "%";
            }
        }

posted @ 2011-06-23 17:58  rui90102  阅读(319)  评论(0编辑  收藏  举报