-
Aug 21st, 2013, 08:00 AM
#1
Thread Starter
Frenzied Member
have problem with making a responsive UI
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
-
Aug 21st, 2013, 08:31 AM
#2
Re: have problem with making a responsive UI
This link to a post I made in a thread here actually lays out the IObservable stuff you need - look it over and ask questions here in this thread
http://www.vbforums.com/showthread.p...=1#post4463947
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|