Threading advice needed... (MVVM)

2 posts, 0 answers
  1. Anders
    Anders avatar
    80 posts
    Member since:
    Dec 2010

    Posted 17 Aug 2011 Link to this post

    Hi Telerik,

    We have the latest WPF library - as the project is progressing we have identified elements that we'd like to 'wrap' in busy indicator display.

    When just adding the control, we are confronted with the need for code to be executed in background worker thread.

    When code had been modified to be executed through the background worker, our code fails as the background thread modifies an ObservableCollection that a control relies on. .Net advices the use of Dispatcher.

    However, if using the Dispatcher, I should 'go through' the control and ask it to modify the underlying collection - and that sort of violates the whole idea of MVVM.

    I'm sure there's some brilliance hidden for me somewhere :) - can you enlighten me as to the recommended way of using BusyIndicator with MVVM?


    Anders, Denmark.
  2. Konstantina
    Konstantina avatar
    2332 posts

    Posted 22 Aug 2011 Link to this post

    Hi Anders,

    I can suggest you to use a Task class, for example:

    Task.Factory.StartNew(() => {
    IsBusy = true;                               
     IsBusy = false;  

    You can find some more information in these help resources:

    Hope this helps.

    All the best,
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top