Wpf progress bar not updating Pink cams xxx uk

Consider the code below for a simple form with a progress bar, a button, and BGW is a Background Worker with Modifiers = Public.

This works but if I change bln Run In Module to true it doesnt update. Crossing threads, I suspect, although I'm a little surprised you're not raising an exception.

wpf progress bar not updating-10

Reviews: "dunfiddlin likes his Data Tables" - jmcilhinney Please be aware that whilst I will read private messages (one day!

) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

I saw that post of John's and I'm beginning to see the light a little. I can see I'm going down the wrong path here so I'll try another tack by creating a class to contain the Background Worker.

The problem in the original example is when I execute the Form1. Report Progress its not getting to the correct Form1.

Its finding the Progress Changed under the default instance of Form1 which is a copy for the worker thread I guess because its being passed By Val. I remembered that passing a parameter can be done By Ref instead of the default.

Since this copy of Form1 is on the worker thread its executing its Progress Changed in that form which is on the worker thread. This in fact creates a new variable which simply contains the address of the original object and therefore doesnt create another instance and the called procedure can modify the original object where it was called from.

IE it doesnt create a copy of the object but rather points back to the original. Now in the module when I reference BGW.whatever its using the original one which gets the correct Progress Changed executed.

I recently received a question from a person we will refer to as “Hingle Mc Cringleberry”, that was related to an old post I did back in 2011 showing how to use the Extended WPF Toolkit’s Busy Indicator control, back when I was the project owner.

In that post, I showed how to use the Background Worker to create a multi threaded application and report progress back to the UI. Well, a lot of things have changed since then, and there are new APIs available to perform multithreading in WPF applications. The problem was that even though the multithreading code was working perfectly, the UI would freeze during the process, although it should remain responsive.

Comments are closed.