This question is about keeping the GUI responsive during longer-running tasks (a few seconds in most cases).
I extensively use threads and a task pattern to execute expensive task in a background thread. But what about GUI updates that takes some time? For example, filling a large string grid or tree view? A thread does not help here because everything needs to be synchronized with the main thread anyway.
I know the problems of Application.ProcessMessages, but currently it seems like the only solution to put calls to ProcessMessages inside the GUI update methods.
Any better ideas?
IMO if the GUI update is the bottleneck (even if BeginUpdate/EndUpdate is used as @The_Fox suggests) then it is time to reconsider the GUI controls used. The standart grids, treeviews, listboxes aren’t simply cut for handling very large number of items. There are many performant thirdparty controls both free and commercial for that purpose.
For a starter, check out VirtualTreeview if the bottleneck is in a grid, treeview or a listbox context.