For some tasks, expressing the progress as a percentage is not possible or you simply don't know how long it will take.
Notice the special String Format syntax, which allows us to show the value with a percentage sign postfix - it might look a bit strange, but please see the String Format article of this tutorial for more information on it.I'm stuck trying to update a progressbar from other threads ran in a different class.Here's a very basic example to demonstrate it with: In this case, I've used a pretty standard approach of showing progress as a percentage (between 0 and 100%), giving it an initial value of 75.Another approach is to use actual minimum and maximum values from a list of tasks you're performing.WPF comes with a handy control for displaying progress, called the Progress Bar.
It works by setting a minimum and maximum value and then incrementing a value, which will give a visual indication on how far in the process you currently are.In most situations you will use the Progress Bar to show progress for some heavy/lengthy task, and this this is where most new programmers run into a very common problem: If you do a piece of heavy work on the UI thread, while trying to simultaneously update e.g.a Progress Bar control, you will soon realize that you can't do both, at the same time, on the same thread.But I didn't understand how to correctly apply this to my code. I tried it with the dispatcher and it still didn't work.I'm still learning WPF and this might be silly way to proceed, i'm looking for a quick and dirty way to get the work done but feel free to tell me what I should redesign for a cleaner application. In Executor cs : public void Run Executor() private void exec Background_Do Work(object sender, Do Work Event Args e) private void exec Background_Run Worker Completed(object sender, Run Worker Completed Event Args e) private void exec Background_Progress Changed(object sender, Progress Changed Event Args e) // TESTING private void update Progress Bar(int i) public delegate void callback_update Progress Bar(int i); public void Run() private void background Worker Remote Process_Do Work(object sender, Do Work Event Args e) private void background Worker Remote Process_Run Worker Completed(object sender, Run Worker Completed Event Args e) private void background Worker Remote Process_Progress Changed(object sender, Progress Changed Event Args e) @Teoman Soygul : I did it using Visio. If you really need to have the ultimate control on the background threads & main (UI) thread updates, here is a fantastic tutorial on that: found a really simple solution to create a thread to run any block of code as well as handle Invocation back to the main thread to change the control's properties. NET 4.5 and the lambda call on the Dispatcher could be adapted to work with earlier versions of . The main benefit is it's just so blissfully simple and perfect when you just need a quick thread for some really basic bit of code.