anagram4wander / VirtualizingObservableCollection

.NET PCL With Virtualizing Observable Collection
http://alphachitech.wordpress.com/2015/01/31/virtualizing-observable-collection/
57 stars 28 forks source link

Situation where data is changed between Count() and GetItemsAt()? #15

Open ghost opened 8 years ago

ghost commented 8 years ago

We're getting data from a SQLite database (on mobile), which can be updated from a web service via another thread.

Therefore there's the possibility that, between calling Count() and getting items, the number of items in the database table have changed due to other updates.

How will VirtualizingObservableCollection handle this? If it won't, any thoughts on how best to mitigate/handle it?

YellowJacket86 commented 8 years ago

I have a similar issue - I have a dynamic database that starts empty and grows quickly. The method GetCount in class AlphaChiTech.Virtualization.PaginationManager uses a member variable _HasGotCount. The first time GetCount is called, it actually queries for the count, then sets _HasGotCount to true. Thereafter, it will never really get the count unless there has been a reset. However, a reset seems to cause everything to update, so calling reset every time a new record is added is really a problem. My solution was to create a method ResetHasGotCount in AlphaChiTech.Virtualization.PaginationManager so that each time I get a new record, I can just reset _HasGotCount to false. That way the next time GetCount is called, it will determine the "real" count and update rows accordingly. Does that seem like a reasonable tweak?

The only other problem I am having right now is poor scroll performance on my DataGrid....