I currently have an application that spawns multiple instances of a single win form. Each instance of the form has a timer which updates a number of controls and some of the properties of the form itself at rate of approx 1 tick/sec. Once the application reaches a certain number of forms it stops painting the ‘updates’ that occur within the timer ticks.
I want to hold the UI thread at the bottom of the timer and allow the form to repaint without calling Application.DoEvents (my understanding is that Application.DoEvents() handles all pending window messages across the application (which could include other timers ‘ticks’? – not sure) when all I want it to process is the redrawing of the form now that a number of the controls have been updated).
It’s not clear to me why you want to call
DoEventsat all. Why not just let the window repaint itself appropriately? What’s wrong with the way it behaves at the moment?Calls to
DoEventsusually indicate that something should be in a background thread – in your case it sounds like it might actually just be that you’ve got too many events going on. If your GUI is so complex that it can’t redraw itself in a second, it sounds like that’s probably a design issue with the UI itself.