财富大搜索今天回放:c# progressBar使用

来源:百度文库 编辑:中财网 时间:2024/05/06 07:11:15
//一个模拟.....也可能不适合你,不知道你的发送文件代码是怎么写的
    private void button3_Click(object sender, EventArgs e)
    {
        Thread thread = new Thread(new ThreadStart(Send));
        thread.Start();
    }

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

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