Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Winforms Progress bar Does Not Update fully (C#)

$
0
0
i am updating progress bar from background worker and removing it when it's value reach 100. i just do not understand why it is not updating or may be taking time to update fully.
My progressbar property
ProgressBar pb = new ProgressBar();
pb.Step = 10;
pb.Minimum = 0;
pb.Maximum = 100;
this way i am updating progressbar
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
     pb.Value = e.ProgressPercentage;
     Application.DoEvents();
}
i am removing my progress bar from backgroundWorker1_RunWorkerCompleted event like this way
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // First, handle the case where an exception was thrown.
            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message);
            }
            else if (e.Cancelled)
            {
                //# "Canceled";
            }
            else
            {
                ProgressBar pb = (sender as MyBackgroundWorker).pbProgress;
                if (pb != null)
                {
                    if (pb.Maximum.Equals(pb.Value))
                    {
                        //pb.Update();
                        //flowLayoutPanel1.Controls.Remove(pb);
                    }
                }
                // Finally, handle the case where the operation  
                // succeeded.
            }
        }
before reaching progress bar fully updated the progress bar is getting removed and this is my issue. i want to remove progressbar from RunWorkerCompleted event when progress bar is fully updated means green part is full. if anyone notice any flaw in the code then please suggest me where & what to change to achieve my goal.

Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>