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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:42:05+00:00 2026-05-12T22:42:05+00:00

I want to update a progress bar from running 1 to 100 with this

  • 0

I want to update a progress bar from running 1 to 100 with this code.

for (int i = 0; i <= 100; i++) {
    System.Threading.Thread.Sleep(100);
    progressBar1.Value = i;
}

But the result is, the UI freeze until looping finish.

I know Dispatcher can help, but I don’t want to split function.

Is there any command to update UI immediately like..

for (int i = 0; i <= 100; i++) {
    System.Threading.Thread.Sleep(100);
    progressBar1.Value = i;
    UpdateUINow();
}

Edit: I’m using WPF, and I use Thread.Sleep to simulate long running process.

In fact, I want any command liked Application.DoEvents. But I cannot find this command in WPF.

  • 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-12T22:42:05+00:00Added an answer on May 12, 2026 at 10:42 pm

    Please don’t sleep in the UI thread. It will freeze your UI – it’s a bad thing to do.

    Either have a timer of some kind (use the right kind of timer and you should be able to get it to fire in your UI thread) or use a separate thread (either via BackgroundWorker, a new separate thread, or the ThreadPool) and make it call back to the UI thread to update it.

    Application.DoEvents is a hacky workaround in WinForms, but the fact that you’ve mentioned a Dispatcher suggests you’re using WPF – is that the case? The kind of timer you should use (if you want to use that solution) will depend on the UI framework you’re using.

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

Sidebar

Related Questions

I want to update a progress bar in winforms using delegate from task. scheduler
I want to Update the Progress bar in my application. I have created a
In linux I want to run a gnome zenity progress bar window from PHP.
I want to change a progress bar use SetValue(int),but it doesn't work,it always change
What I want: Update all new commits from server with my local repository in
I want to provide a progress bar for my users who upload very large
So you have a long running process, perhaps with a progress bar, and you
I want to display progress from a BackgroundWorker to a ProgressBar in the UI.
Alternatively is it possible to manually update the built in progress bar? Basically I
Suppose i want to track the progress of a loop using the progress bar

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.