Quantcast
Channel: VBForums - WPF, WCF, WF
Viewing all articles
Browse latest Browse all 256

have problem with making a responsive UI

$
0
0
Hi!

I have implemented along running operation in one of the viewmodels in my WPF application. On the view I have a progressbar where I have set up a Binding expression to two properties in the viewmodel maxvalue and currentvalue.

I have a long running method like this:

Code:


void ProcessData(List<Widget> listToEvaluate)
{
  foreach(Widget w in listToEvaluate) {
        // Analyze here...
      currentvalue++;
  }
}

The problem with the above code is that the progressbar jump directly from 0 to say 4000 when this method has finished. I want a smooth update after each tinme the currentvalue property is increased. Of course this is a threading issue since all this code runs on the UI thread. Back in the days I would have solved this with a BackgroundWorker object.

But how do I solve this in the WPF era? We use Framework 4.0 so I can't benefit from async await. I have looked around and it seems they like to use the RX framework with their generic IObservable and IObserver objects and extension methods like Subscribe, ObserveOn etc. But thre is no one to ask about this and I can't find any good examples in the existing code.

Can anyone explain how this can be done, or provide an example of some sort that uses the RX framework to solve this? I am a bit lost here...

/S

Viewing all articles
Browse latest Browse all 256

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>