views:

56

answers:

2

I have a ListView that is binded to my custom collection.

At run time , I am updating the certain properties of my entity in my custom collection in my ViewModel. At the same time , I am also doing the custom sorting in the listview.

The custom sorting is applicable when I click on the any column header of the listview.

For example, I am updating the current datetime on my entity on every 5 seconds and simulaneously , I am applying custom sorting based on DateTime.

(The Listview is third party control).

Hence I am doing two operations on my custom collection at the same time.

Should I pass the dispatcher of my control in the view model and call any methods ( which updates any entity in my custom collection ) through UI dispatcher ?

A: 

If want to update u r ui u have to use dispatcher, there is no other way to update the ui.

 Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate{ ///You can update your Ui here });
Malcolm
A: 

Are you using your thread only for updating the entity properties? If so, using dispatcher will result in erasing the meaning of using a thread since all the operation will be done by UI thread ultimately. You can better put your sorting logic in a different thread. Some code would help anyways.

Veer
Sorting logic is inbuilt in a listview (third party control ) and it seems that the listview do it in the UI thread only.
Ashish Ashu
@Ashish Ashu: Are you then using your thread only for updating your entity property? And how do you do that for every 5 sec? using a stopwatch?
Veer
Its a call back method exposed from another dll. It sends the notification and based on that I changed the status property of an entity in the collection.
Ashish Ashu
This seems to be the same case as the Jason Dolinger's example app in this link http://www.lab49.com/files/videos/Jason%20Dolinger%20MVVM.wmv He uses the Dispatcher to alter the collection as items are retrieved from a service.
Veer