William
William

Reputation: 3405

Alternative to INotifyPropertyChanged for UI Updates

I am trying to create a system where the user interface is not updated EVERY time a property of one of my business objects is changed, but instead is only updated in a controlled manner.

This is my reasoning:

  1. The business objects are updated many hundreds of times per second, but it seems to me that the user really only needs to see an update every 250 or so milliseconds. I was thinking about having a timer that elapses every 250 milliseconds and every time it elapses to call a method which would tell the UI that it needs to refresh itself.

  2. The UI is fairly large and I wanted to make it so that the only control that would be refreshing themselves would be the ones that are currently being viewed by the user.

I am aware of the INotifyPropertyChanged model but wouldn't this unnecessarily update the UI every time anything was updated?

I tried using .RefreshDataSource(), but I was wondering if there is a better way?

Upvotes: 0

Views: 1129

Answers (2)

Ana Betts
Ana Betts

Reputation: 74692

You can choose when NotifyPropertyChange is called - why not make a base class that implements INotifyPropertyChanged by suppressing frequent calls?

Upvotes: 1

Michael Schnerring
Michael Schnerring

Reputation: 3661

I am aware of the INotifyPropertyChanged model but wouldn't this unnecessarily update the UI every time anything was updated?

Well, just if you call NotifyPropertyChanged("PropertyName") in the setter of the property, which is shown on the UI. Because this actually forces the UI to update everytime the property is set again - means many hundreds of times per second per property. You could also call NotifyPropertyChanged("PropertyName") in the method, which gets called everytime your timer elapses. So there's no need of using RefreshDataSource() instead of INotifyPropertyChagend.

Upvotes: 2

Related Questions