我正在运行一个BackgroundWorker 线程来执行一项耗时的任务。耗时的任务在另一个类中。我需要将在BackgroundWorker 上运行的这个单独的类所取得的进度传递回Main Form1 类。我不知道如何处理这个问题。请提供建议。先感谢您。
**// Main Form1 UI Class**
public void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
{
//e.Argument always contains whatever was sent to the background worker
// in RunWorkerAsync. We can simply cast it to its original type.
DataSet ds = e.Argument as DataSet;
this.createje.ProcessData(this.ds);
}
private void backgroundWorker2_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
this.progressBar1.Minimum = 0;
this.progressBar1.Maximum = CreateJE.max;
this.progressBar1.Value = e.Recno;
}
**//Other Class called CreateJE**
public void ProcessData(DataSet ds)
{
//Do time consuming task...
for (int i …Run Code Online (Sandbox Code Playgroud)