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 7611479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:40:34+00:00 2026-05-31T01:40:34+00:00

Im trying to update a progress bar while doing some data type checks on

  • 0

Im trying to update a progress bar while doing some data type checks on a separate thread and there seems to be a delay between what value the progress bar is at and the value which is actually show.

The following code is executed by the non-GUI thread and is used to raise the event.

    protected virtual void OnUpdateProgressBar(object sender, ProgressBarEventArgs e)
    {
        EventHandler<ProgressBarEventArgs> TempHandler = UpdateProgressBar;

        //Avoid possible race condition.
        if (TempHandler != null)
        {
            TempHandler(this, e);
        }
    }

I have created a separate class for updating the progress bar and when i create an instance of it, i pass a reference to the progress bar. Below is the entire class.

public class ProgressBarChanged
{
    ProgressBar statusBar;

    public ProgressBarChanged(ProgressBar pb)
    {
        statusBar = pb;
        statusBar.Value = 0;
    }
    public ProgressBarChanged()
    {
    }

    public void subscribeToEvent(DataVerification test)
    {
        test.UpdateProgressBar += new EventHandler<ProgressBarEventArgs>(incrementPB);
    }

    public void incrementPB(object sender, ProgressBarEventArgs e)
    {
        Action action = () =>
        {
            if (e.CurrentRow == e.FinalRow - 10)
            {
                int i = 5;
            }
            statusBar.Maximum = e.FinalRow;
            statusBar.Value = e.CurrentRow;
        };

        if(statusBar.InvokeRequired)
           statusBar.Invoke(action);
        else
            action();
    }
}

I have uploaded a screen shot showing the progress bar and the actual values.
Any ideas???

Thanks

enter image description here

  • 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-05-31T01:40:35+00:00Added an answer on May 31, 2026 at 1:40 am

    The progessbar is a simple feedback to the user, not a piece of exact instrumentation. It’s a pacifier.

    It also incorporates it’s own async logic to update the screen (independent of the message loop). This makes that it may run a little behind.

    What’s the big deal?

    To get more accurate results, divide your range into < 100 segments and do fewer updates.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to update the progress bar in a AsyncTask while downloading some stuff..
I am trying to update a progress bar in my main form while a
I am trying to add some text to a Tool Strip Progress Bar but
I'm trying to make a progress bar that updates the user on the progress
I'm trying to display an update progress loading image whenever my update panel does
I am trying to update a field in a table with data from another
I am trying to update a field of type spFieldUserValue, you know a, PeoplePicker.
I'm trying to set up a view that gives feed back via progress bar
I am trying to use progress bar to show the progress of a script.
I am trying to use the basic progress bar however I am unable to

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.