none
BackgroundWorker问题 RRS feed

  • 问题

  •   private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
            {
                for (int i = 0; i < 10; ++i)
                {
                    Thread.Sleep(500);
                    backgroundWorker2.ReportProgress(i * 10);
                    if (backgroundWorker2.CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }
                }
                e.Result = sr.Search(agent, start, end);
            }
            private void backgroundWorker2_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
            {
                dataGridView1.DataSource = e.Result;
                progressBar1.Value = 0;
            }

            private void backgroundWorker2_ProgressChanged(object sender, ProgressChangedEventArgs e)
            {
                this.progressBar1.Value = e.ProgressPercentage;
            }

     

     

    报错:此 BackgroundWorker 声明它不报告进度。请修改 WorkerReportsProgress 以声明它报告进度。

    2010年8月22日 5:44

答案

  • 你好

    你可以加以下的CODE 去 声明它报告进度

    backgroundWorker2.WorkerReportsProgress=True

    Please correct me if my concept is wrong


    Chi
    2010年8月22日 6:06
    版主

全部回复