Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8298359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:44:33+00:00 2026-06-08T15:44:33+00:00

(Sorry for the not-so-good-title, I’m not sure how my problem can be solved, thus

  • 0

(Sorry for the not-so-good-title, I’m not sure how my problem can be solved, thus what is the question I need to ask 🙂

Context

I use a progress bar to inform the user of the progress of a task. The task is in fact done in two steps, each of them taking approximately half of the total time to be performed. I only know the length of the second task just before starting it (because it depends on the results of the previous task), so I can’t know the maximum progress at the very beginning. That is why I change the maximum progress of my progress bar before the second task.

This is basically how I do it:

// 1st step
progressBar.Maximum = step1Objects.Count * 2; // "2" because the step will take 
                                              // half of the total process
progressBar.Value = 0;
foreach (SomeObject step1Object in step1Objects) {
    // Build step2Objects
    progressBar.Value = ++progress;
}
// At this moment, the progress bar is half filled

// 2nd step
progressBar.Maximum = step2Objects.Count * 2;
progressBar.Value = step2Objects.Count;
// When we start this step, the progress bar is already half filled
foreach (SomeObject step2Object in step2Objects) {
    // Do something
    progressBar.Value = ++progress;
}
// At this moment, the progress bar is totally filled

Problem

When I get to this line:

progressBar.Maximum = step2Objects.Count * 2;

… the progress bar is for a short instant not half filled anymore because step1Objects.Count is very little compared to step2Objects.Count. So the progress bar does something like that (that’s what the user sees):

>          |
=>         |
==>        |
===>       |
====>      |
=====>     |  End of step 1
=>         |  progressBar.Maximum = step2Objects.Count * 2;
=====>     |  progressBar.Value = step2Objects.Count;
======>    |
=======>   |
========>  |
=========> |
==========>|

Question

How can I avoid this “glitch”?

I think that the thing to do is stop the refresh of the progress bar between the two steps. I was thinking at something like BeginUpdate/EndUpdate, but it doesn’t seem to exist for progress bars…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T15:44:41+00:00Added an answer on June 8, 2026 at 3:44 pm

    You write that both tasks are approximately half of the total time to be performed.

    progressBar.Maximum = 100;
    
    var stepPercentage = 50 / step1Objects.Count;
    foreach(SomeObject step1Object in step1Objects)
    {
        progressBar.Progress += stepPercentage;
    }
    
    progressBar.Progress = 50;
    stepPercentage = 50 / step2Objects.Count;
    foreach(SomeObject step2Object in step2Objects)
    {
        progressBar.Progress += (stepPercentage + 50);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry about the stupid question however I can't see/ not good enough to solve
Sorry but I am not sure how to ask this question but I am
guys, sorry for the title of the post... i'm not so good in english,
SQL Server 2008: Sorry for the possibly non-informative title but I'm not sure quite
Not sure if I'm being too clear with the title. Sorry, it's late and
I'm sorry if the title is not very good, any suggestions are welcome. The
My English is not good, sorry... I use tablesorter (tablesorter.com) to sort table in
Firstly, i am sorry if the title does not properly describe my problem, but
(Sorry I'm not good at English) I haved created a custom BaseAdapter to show
I'm not good in English. What wrong with my text ^^ sorry :) I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.