Performing expensive operations on ObservableCollection.CollectionChanged

In my model, I need to know when a particular collection changes, so I subscribe to the CollectionChanged ObservableCollection event. This works very well, except that the operation is quite expensive.

So, when is the client code:

foreach(Item i in longList)
{
    model.ObservableCollection.Add(i);
}

I perform an expensive operation for each iteration when all that matters is the result after adding the last element.

Is there a way to cancel the current event handler if another CollectionChanged event was raised while the first is still running - and then go on to handle the last event?

+3
source share
2

ObservableCollection . BeginUpdate EndUpdate() IsUpdating.

+3

. , , - , .

, CollectionChanged, . , CollectionChanged, , "tick".

-2

Source: https://habr.com/ru/post/1728945/


All Articles