Wpf listview binding observablecollection not updating

posted by | Leave a comment

When the simple, synchronous version runs on the UI thread, WPF does very little immediate work for each item we add to the to that collection, so it’ll be looking for change notification events—but WPF won’t fully process those changes until our code has finished with the UI thread.

Data binding defers its work until the dispatcher thread has no higher priority work to do.

wpf listview binding observablecollection not updating-66wpf listview binding observablecollection not updating-57wpf listview binding observablecollection not updating-26

However, since the IO only slows things down by about 1.4 seconds when things aren’t in the cache, it’s hard to see how the asynchronous code might make up the deficit even in more favourable conditions.

(My system drive is a pair of SSDs, but these logs live on my larger data drive, which is of the spinning rust variety.) It only gets up to full speed once the files are in the OS’s cache, and under those circumstances, asynchronous code has much less to offer.

The whole point is to free up threads while slow IO is in progress, but if everything you need is already in memory, the IO won’t be so slow.

Now this might scare you off the C# asynchronous language features, because it makes them seem slow, but this is not a fair test.

The reason this takes so much longer is that we’ve given the program much more work to do.

Leave a Reply

Hot chat lines always free