We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Progress Bar not working as expected. what am I missing.

On my Inoivce form, i placed a panel. with two controls. A label called ProgressBarMessageLabel and a ProgressBarAdv and named it ProgressBar1. I set the panel to invisible.

In my form code, the user clicks the Save Button and in my save routine i prepare to process the data as follows.

IEnumerable<Member> membersToProcess = FetchMembersToProcess();

int rowsToProcess = membersToProcess.Count();

ProgressBar1.Step = rowsToProcess / 100;
ProgressBarPanel.Visible = true;
ProgressBarMessageLabel.Text = "Processing members. please wait...";

foreach(Member m in members)
{

        ProgressBar1.Increment();       
        ProgressBar1.Refresh();

      // process member record and save
       // DoSomeProcess on member object in memory;
        SaveMember();
}

ProgressBarPanel.Visible = false;


I run the application but the progress bar doesn't move and the text doesn't display in the label. What am i doing wrong? Since i am looping through the data i shouldnt need a background worker should I?

Bill






4 Replies

SK Senthil Kumaran Rajan Syncfusion Team June 24, 2014 01:19 PM UTC

Hi William,

Thanks for using Syncfusion Product,

We would like to let you know that your requirement of ProgressBarAdv can be achieved by using the below code snippet. Please have the below code snippet and attached sample.

Code Snippet[C#]:
for (int rowsToProcess = 1; rowsToProcess <= 10000; rowsToProcess++)
            {

                this.progressBar1.Value = (rowsToProcess / 100);
                progressBar1.Refresh();
                label1.Text = "Processing members. please wait...";
                
               
            }
            if(progressBar1.Value==100)
            {
                MessageBox.Show("Process completed");
                progressBar1.Value = 0;
                this.label1.Text = "ProgressBarMessageLabel";
            }       

Please let us know if you have any other concerns.

Regards,
R.Senthil kumaran

Attachment: progressbar_75189a1b.zip


WG William Gower June 24, 2014 01:49 PM UTC

I tried replacing my code as shown in your reply but the progress bar never gets refreshed during the entire time it is displayed. The label text is not shown and the progress bar remains at 0% during the entire process. The process takes about 2 minutes to room. Its like the UI is not getting control back once the loop starts.

Bill



WG William Gower June 24, 2014 02:39 PM UTC

After running a few tests and stepping through the code I can confirm the problem is caused by the UI not getting back control during the processing. In my loop, I am just processing a record at a time and then saving it. I am using Devforce IdeaBlade 2012 for my EF tool. I am not sure why the UI is not getting back control. I did notice that at the every end of the processing for a brief instance the progress bar gets 1 block colored says 1% and then vanishes due to the Visible = false statement being executed. Do I need to run the displaying and refreshing of the progress bar in another thread eg. BackgroundWorker. If I do how would i do that?

Bill



SK Senthil Kumaran Rajan Syncfusion Team June 25, 2014 01:38 PM UTC

Hi William,

Thanks for your update,

We would like to let you know that we have prepared a sample for your requirement of  "ProgressBarAdv"  and it is attached below.

Please let us know if you have any other concerns.

Regards,
R.Senthil kumaran

Attachment: ProgressbarSample_361caca1.zip

Loader.
Live Chat Icon For mobile
Up arrow icon