This is a migrated thread and some comments may be shown as answers.

Threading advice needed... (MVVM)

1 Answer 139 Views
BusyIndicator
This is a migrated thread and some comments may be shown as answers.
Anders
Top achievements
Rank 1
Anders asked on 17 Aug 2011, 11:19 AM
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?

Thanks,

Anders, Denmark.

1 Answer, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 22 Aug 2011, 01:07 PM
Hi Anders,

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

Task.Factory.StartNew(() => {
IsBusy = true;                               
Thread.Sleep(1000);                            
 IsBusy = false;  
}

You can find some more information in these help resources:


Hope this helps.

All the best,
Konstantina
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 >>

Tags
BusyIndicator
Asked by
Anders
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Share this question
or