我用的是时间控件来判断的,
backgroundWorker里面写你的代码
在 backgroundWorker_RunWorkerCompleted事件里面
结束时间控件的运行
         private void timer_Tick(object sender, EventArgs e)
        {
            BarRoll();            
        }        delegate void CurrentBarRoll();
        private void BarRoll()
        {
            if (this.InvokeRequired)
            {
                CurrentBarRoll currentBarRoll = new CurrentBarRoll(BarRoll);
                this.Invoke(currentBarRoll, new object[] { });
            }
            else
            {
                progressBar.PerformStep();
                if (progressBar.Value == progressBar.Maximum)
                {
                    progressBar.Value = progressBar.Minimum;
                }
            }            
        }

解决方案 »

  1.   

    backgroundWorker1.ProgressChanged += ...详细见:
    http://msdn.microsoft.com/zh-cn/library/system.componentmodel.backgroundworker.aspx
      

  2.   


    private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
            {
    //做你费时的操作
    UpdatePlanInfo();//更新进度
            }//更新进度的委托
            delegate void DelegateUpdatePlan();        //更新进度
            private void UpdatePlanInfo()
            {
                if (this.InvokeRequired)
                {
                    DelegateUpdatePlan delegateUpdateItem = new DelegateUpdatePlan(UpdatePlanInfo);
                    this.Invoke(delegateUpdateItem);
                }
                else
                {
                    progressBar.PerformStep();
                }
            }
      

  3.   

    改一下
    private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
            {
    for(int i =0;i<100;i++)
    {
    UpdatePlanInfo();//更新进度
    }
            }
    嘿嘿~~
      

  4.   

    你的费时操作有没有循环一类的?在完成一次循环,调用一下UpdatePlanInfo();方法,进度条就会走一下
      

  5.   

    线程间操作无效: 从不是创建控件“dgvResult”的线程访问它。费时操作不是循环类型的,就是下面这句话
     dgvResult.DataSource = MyClass.Search(searchType, txtSearch.Text.Trim()); 
    这句话要操作很多数据,所以很费时。