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

  • Home
  • SEARCH
  • 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 3663626
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:33:06+00:00 2026-05-19T01:33:06+00:00

Basic Goal is that i have four progress bar and want to run them

  • 0

Basic Goal is that i have four progress bar and want to run them at once as button is pressed and i donot have to use background worker have to do by this.

 var t = new Thread(() =>
            {
                try
                {

                }
        });
        t.SetApartmentState(ApartmentState.STA);
        t.Start();

I tried and codded

 for (i = 0; i < 4; i++)
            {
                var t = new Thread(() =>
                {
                    for (double x = 0; x < 10000; x = x + 0.5)
                    {
                        progressVal=(int)x;
                        this.Invoke(new EventHandler(ProgressBar));
                        Thread.Sleep(2);

                    }
                });
                t.SetApartmentState(ApartmentState.STA);
                t.Start();
            }

 private void ProgressBar(object sender, EventArgs e)
        {
            progressBar1.Value=progressVal;
        }

but cannot think of idea how to manuplate other 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-05-19T01:33:07+00:00Added an answer on May 19, 2026 at 1:33 am

    I would put the progress bars into an array:

    var pBars = new[] { progressBar1, progressBar2, progressBar3, progressBar4 };
    foreach (var pBar in pBars)
    {
        new Thread(currentPBar => 
        {
            for (double x = 0; x < 10000; x = x + 0.5)
            {             
                var progress = (int)x;
                Action<ProgressBar, int> del = UpdateProgress;
                Invoke(
                    del, 
                    new object[] { (ProgressBar)currentPBar, progress }
                );
                Thread.Sleep(2);
            }            
        }).Start(pBar);
    }
    

    and the UpdateProgress method:

    private void UpdateProgress(ProgressBar pBar, int progress)
    {
        pBar.Value = progress;
    }
    

    This being said, using a BackgroundWorker is far more adapted to your scenario.

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

Sidebar

Related Questions

I have a pretty basic script that echos local administrator accounts. My goal is
I have a set of four images, and my functionality goal is so that
Basic question here - I have many lines of code that look something like:
My Basic Goal A Rails app that can load new content via Ajax while
I have a basic form that I am using as a dummy to test
Goal: Provide a web service using Visual Basic or C# or .NET that interacts
I want to have a div that animates the currently active image out of
So I have this basic html form. My goal is to pass the values
I have a GUI that is for all intents and purposes really basic. A
My goal is to make an apprequest button in my app that invites friends.

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.