Yes, I'm processing a large amount of data using a class wrapping an array of classes. I process them in a background thread and drive the progress indicators via timers as has been discussed here.
But how to load the listbox with a large amount of data, and also show progress? The listbox must be updated from the main thread because its a GUI element, but using a single big loop on the main thread doesn't allow me to show any progress since ProgressBar.Refresh no longer works.
A 200 ms timer basically introduces 200 ms of idle time which I think would significantly slow down the listbox loading. A timer can start code if the app is idle, but doesn't do anything if the app is already busy (neither start nor stop).
I'm gravitating towards the idea of a 1 ms timer, where the timer's action event has a loop that reads items off of a 100k element array and adds them to the listbox, but after 500 ms the loop sets the progress indicators and exits the timer event (even if the loop isn't finished). This lets the main event loop run, including firing that timer again very quickly to resume processing for another 500 ms.
Basically the short timer is just used as a way to start code that itself can track time and periodically exit and yield a small amount of time back to the main event loop.
This seems like a workable approach, but I'm open to other ideas too....
Each time I explain it, it helps me understand it better. :-)