The Progress Bar is, just like other standard WPF controls, rendered to match the visual style of the operating system.

Please be aware that while the Background Worker does help a lot with multithreading related problems, there are still some things you should be aware of, so please have a look at the Background Worker articles in this tutorial before doing anything more advanced than a scenario like the one above.

For some tasks, expressing the progress as a percentage is not possible or you simply don't know how long it will take.

As soon as the loop, which represents our lengthy task, is done, the Progress Bar will look like this: That really didn't help your users see the progress!

Instead, we have to perform the task on a worker thread and then push updates to the UI thread, which will then be able to immediately process and visually show these updates.

a Progress Bar control, you will soon realize that you can't do both, at the same time, on the same thread.

Or to be more clear, you can, but the Progress Bar won't actually show each update to the progress before the task is completed, which pretty much renders it useless.

Here’s the code that goes into our cancel button’s Click event: Here we call the Cancel Async method.

However, this only sets a flag and, as shown above, our Do Work method has to check for a Cancellation Pending state.

Now we’re ready to create our Background Worker object. Updating Form Controls In the Progress Changed event, we get to process our values from our Do Work method.

Notice that we tell it that we want to have it report progress and support cancellation. Here’s the code: In this routine, the progress bar and the listbox are updated with values from the worker thread.

Otherwise, the work will continue until the Do Work routine is exited.