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

Goal: Provide a web service using Visual Basic or C# or .NET that interacts
Basic premise: I have a Room which publishes an event when an Avatar enters
The basic idea behind a Cancel button is to enable closing your window with
I have a POCO classes that I am using with NHibernate in a WCF
We're in the initial stages of a large project, and have decided that some
basic problem: i need to create real customized templates for my django forms. That's
Basic requests are: human readable / text format (for easy version control) online (for
Basic question : How to I create a bidirectional one-to-many map in Fluent NHibernate?
The basic problem is like this: A subscriber has successfully replicated a row from
My basic question is, in .NET, how do I clone WebControls? I would like

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.