Reputation: 201
My app is freeze while I click the button to add items to list control. I'm doing it simple:
for (unsigned i = 1; i < 15000;++i)
{
listcontrol1.InsertItem(i, L"item list");
}
I also tried using a background thread but the same results. Any idea how to do this correctly without blocking the user interface ?
Upvotes: 0
Views: 354
Reputation: 754
As Sheng Jiang stated the virtual list is the best solution for such a great list. But you can improve the performance avoiding control paintings during insertion:
listcontrol1.SetRedraw(FALSE);
for (unsigned i = 1; i < 15000; ++i)
{
listcontrol1.InsertItem(i, L"item list");
}
listcontrol1.SetRedraw(TRUE);
Upvotes: 1
Reputation: 15261
pouring 15k messages into the message pump is going to be slow.
Better use a virtual list control with proper caching. See the VListVW Sample in %Windows SDK Dir%\Samples\winui\controls\common\vlistvw for working code.
Upvotes: 1