For example, if you want to update a displayed progress bar the code to update it from a background thread would look like this: Keep the dispatched routine short to ensure the maximum responsiveness of the UI for the user.
The only thing to note that initially the Cancel button and progress bar visibility is set to hidden.
Here is the code where we launch the Do Work event operation, but more importantly we pass in data which the Do Work can use to perform its operations.
The goal of this article is to create a circular progress bar (see the examples in the screenshot above) as simple as possible, that is working in Silverlight and WPF and only uses the path arc segment. The properties “Stroke” and “Stroke Thickness” of the path element are bound to dependency properties of the user control.
We’ll get to the code behind class in a minute, but let’s get the XAML code right.
The simple way to fix this is to simply do all the processing in the UI thread, but mostly that is not a practical solution.
The proper way to deal with this situation is to dispatch the requested UI-related operation to the UI thread using the Dispatcher class.We get a numeric percentage which moves the bar along and incremental movements.The cancel is similar because we do the opposite of the initiation code above by hiding the controls and informing the user of the stop action. I'm having a problem with continuous refreshing of progress bar (increment a progress bar until is full and do it in loop).My goal is to fill my progress bar smoothly (in aprox. Here is snippet of my code, it's working but when progress is about 80% it will be suddenly reset to 0 (which is OK, but it should be done on 100%). Even if I use the sync Exec (thanks to which it should execute all the UI runnables until it continues further), the UI runnables were executed but UI was not updated (at least not in realtime but with delay)... it looks like every update of progress bar status is delayed on UI and when the main thread resets the progress bar back to 0 the UI is not displaying the actual state (which is really 100% in non UI thread) but it is only on 80% (because of some sort of paint delay).