Hi. I have a background worker that stops after 100 iterations. Like this:
BackgroundWorker bgWorker = new BackgroundWorker();
bgWorker.WorkerReportsProgress = true;
bgWorker.WorkerSupportsCancellation = true;
bgWorker.DoWork += new OpenNETCF.ComponentModel.DoWorkEventHandler(this.bgWorker_DoWork);
bgWorker.RunWorkerCompleted += new OpenNETCF.ComponentModel.RunWorkerCompletedEventHandler(this.bgWorker_RunWorkerCompleted);
bgWorker.ProgressChanged += new OpenNETCF.ComponentModel.ProgressChangedEventHandler(this.bgWorker_ProgressChanged);
private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
{
for(i=0; i<300; i++)
{
bgWorker.ReportProgress(i, i);
}
}
private void bgWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
this.labelProgress.Text = e.UserState.ToString();
}
private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
MessageBox.Show("finished loading...");
}
What happens is that the labelProgress' value stops at 100, and the messagebox pops up and says "finished loading...".
Anybody have an idea of what is wrong. Why does the thread stop at the 101 iteration?
Thanks in advance.