进度条

来源:转载

  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 + "%";
            }
        }


分享给朋友:
您可能感兴趣的文章:
随机阅读: