c# opennetCF background worker stops after 100 iterations

Posted by ikky on Stack Overflow See other posts from Stack Overflow or by ikky
Published on 2010-03-26T09:27:00Z Indexed on 2010/03/26 9:33 UTC
Read the original article Hit count: 517

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about opennetcf