New Posts New Posts RSS Feed: Disable Collection Change Notifications
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Disable Collection Change Notifications

 Post Reply Post Reply
Author
chuckc View Drop Down
Groupie
Groupie


Joined: 27-Feb-2010
Posts: 54
Post Options Post Options   Quote chuckc Quote  Post ReplyReply Direct Link To This Post Topic: Disable Collection Change Notifications
    Posted: 05-Mar-2013 at 12:54pm
I have a RelatedEntityList bound to a grid.  When the user adds a large number of items to the RelatedEntityList using the Add method, I see a lot of notifications that degrade UI performance. 

What is a good way to disable or minimize these notificatons?  The RelatedEntityList doesn't appear to have an AddRange method, which would probably help minimize notifications.  Can I temporarily turn off notifications from RelatedEntityList?  Or at the EntityManager?

Thanks for your help.
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 06-Mar-2013 at 11:48am
Hi chuckc,

Unfortunately, it's not possible to disable RelatedEntityList CollectionChanged event.

I'm creating a feature request for an AddRange method.

sbelini
Back to Top
stephenmcd1 View Drop Down
DevForce MVP
DevForce MVP


Joined: 27-Oct-2009
Location: Los Angeles, CA
Posts: 166
Post Options Post Options   Quote stephenmcd1 Quote  Post ReplyReply Direct Link To This Post Posted: 13-Mar-2013 at 11:51am
This might not be directly related to your problem but I thought I'd mention it here for completeness.  I also just happened to be looking at this kind of thing so it's fresh in my mind. 

It is possible to disable these notifications.  The following code will add 10 child "OrderDetail" rows to a RelatedEntityList without raising any change notifications:
//The 'parent' entity
var order = new Order();

//Disable change notifications on the parent entity's group (maybe check if it is already
//  disabled so you don't mess with the existing state?)
order.EntityAspect.EntityGroup.ChangeNotificationEnabled = false;

//Get the RelatedEntityList
RelatedEntityList<OrderDetail> entityList = order.OrderDetails;

//Add 10 detail rows - none of these will trigger a CollectionChanged event
for (var i = 0; i < 10;i++ )
    entityList.Add(new OrderDetail());

//Re-enable notifications for future operations
order.EntityAspect.EntityGroup.ChangeNotificationEnabled = true;

However, I'm not sure that this would actually help you out if your UI is bound to the related entity list.  You basically would have added 10 items behind its back.....so they wouldn't show up.  Perhaps you could somehow force the UI to 'refresh' itself after you did the bulk loading.  Or you may just need to wait until an AddRange() method gets added.

You can read more about EntityGroup.ChangeNotificationsEnabled on the Listen for Changes wiki page.  I'll specifically quote this note/warning:

There may be cases where a developer wants to suppress all "change notification" within an EntityGroup for a period of time.  This can be accomplished by setting the ChangeNotificationEnabled property to 'false'. Note that this will effect change notification at the EntityManager level (EntityChanging, EntityChanged) as well as at the Entity level (INotifyPropertyChanged).
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down