Results 1 to 2 of 2

Thread: have problem with making a responsive UI

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    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

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width