the problem is quite simple : Basically my View should display data coming from a WCF service. The data is updated asynchronously with an high frequency, so the GUI should be updated accordingly when the data on server side changed.
The View is showing a lot of data, so basically it's binding 50/60 fields exposed in the ViewModel.
The Model part is basically a POCO object which contains the 50/60 fields displayed in the GUI. Yes, the ViewModel is exposing the Model object to the View. (Note that the Model object implements INotifyPropertyChanged, in order to notify the View when a property value changed.)
Now, I wrote a "DataService" layer which interacts with the WCF service, and it's responsible of updating the Model according to the data returned by the WCF service. When the data is updated on server side, the WCF service, for performance reasons return to the client only the set of fields that are changed.
So, in the DataService there is an event handler which manages the wcf service updates like the following :
void OnServiceUpdated(UpdateArgs args)
{
foreach(Field field in args.ChangedFields)
{
if(field.Key == "BetName") _modelBet.BetName = field.Value;
else if(field.Key == "BetUser") _modelBet.BetUser = field.Value;
[...]
//the same for 50 fields...
}
}
Now this horrible code which update the model, is needed because we want to update only the fields of the model which are not changed on server side. (Note that the wcf service API cannot be changed).
My question is : What do you suggest in order to improve the performance of the "OnServiceUpdated" handler?
Thanks in advance, Jhon