3 ms·
> DoEvents() is a once-popular but very dangerous kludge for Windows applications that don’t want to deal with multithreading.* > The problem is that you never
by kazinator 5y ago
> DoEvents() is a once-popular but very dangerous kludge for Windows applications that don’t want to deal with multithreading.*
> The problem is that you never know exactly what DoEvents() is going to do. Other parts of your application may receive Windows messages (say, if the user clicks somewhere else), and they can start running their code in the space that you create when you call DoEvents(). This sounds bad, but it’s actually a lot of fun (if you like late-night debugging), because the result is just a little bit different on every computer!
Oh, but if instead you introduce threads, you won't have any such problems, right?
Maybe you're supposed to change the state of your program to "calculation running" so that when UI events are processed in the middle of DoEvents, this state is observed.
If the calculation ran in a thread, you'd probably track that; the UI would know that the calculation is running and certain actions would be disabled or handled differently.