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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:35:55+00:00 2026-06-15T21:35:55+00:00

What I want is when some method is doing some task UI keeps itself

  • 0

What I want is when some method is doing some task UI keeps itself active and I want to show the progress of the work in a progress-bar.

I have a method, a BackGroundWorker and a Progressbar. I want to call the method when BackGroundWorker starts running and show the progress. The method contains a loop. So, it can report the progress.

So, what can be done?

private void Form1_Load(object sender, EventArgs e)
{
    // TODO: This line of code loads data into the 'dataSet1.TBLMARKET' table. You can move, or remove it, as needed.
    myBGWorker.WorkerReportsProgress = true;
}

private void myBGWorker_DoWork(object sender, DoWorkEventArgs e)
{
    parseFiles();
}

private void myBGWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
    myProgressBar.Value = e.ProgressPercentage;
}

private void myBGWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
    MessageBox.Show("Done");
}

private void parseButton_Click(object sender, EventArgs e)
{
    myBGWorker.RunWorkerAsync();
}

public void parseFiles()
{
  for()
  {
     //parsing
     myBGWorker.ReportProgress(...);
  }
}

But it’s not working. The Progressbar is not updating. Only a small progress is showing after the MessageBox “Done”.

  • 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-15T21:35:57+00:00Added an answer on June 15, 2026 at 9:35 pm

    Instead of using one ParseFiles method (which should depend on myBGWorker) use loop and method which parse one file. Report progress percentage in that loop:

    private void parseButton_Click(object sender, EventArgs e)
    {
        parseButton.Enabled = false;
        myBGWorker.RunWorkerAsync();
    }
    
    private void myBGWorker_DoWork(object sender, DoWorkEventArgs e)
    {
       for(int i = 0; i < filesCount; i++)
       {  
           ParseSingleFile(); // pass filename here
           int percentage = (i + 1) * 100 / filesCount;
           myBGWorker.ReportProgress(percentage);
       }
    }
    
    void myBGWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
        myProgressBar.Value = e.ProgressPercentage;
    }
    
    void myBGWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
        parseButton.Enabled = true;
        MessageBox.Show("Done");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing some work with stats, and want to refactor the following method :
I have some XML that I want to parse using the lxml method in
I have some data calculation method (let it be myMethod:), and I want to
I want to pass an uninitialized object pointer to some method. Within that method
I want to return some errors to my jquery method. What is happening is
I want to find a method to include some files based on the current
I want to override the Tostring() method for changing some characters. Is it possible?
I'm using CoreLocation,and I want to call a method to do some computations on
I have a page where I want to display some points on map. I
Is someone intelligent there who can answer this question? I m doing some task

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.