is much superior to a for/next loop, since sleep allows the processor to move on to other tasks (system or other programs), whereas a for/next loop hogs the processor for no good reason.
The drawback of using Sleep() is that your program stops receiving Windows messages and looks like a dead application.
Using a timer is a better solution. You create the timer and then use the handle OnTimer of update counter that will trigger the 'Do Something' and a little bit later the 'Do Something else'
Actually that's true. A trigger can be better when you're waiting for a specific event, rather than just waiting an arbitrary amount of time...
However, Sleep() is often used in multi-threaded applications to allow the other threads to have processor time. These are usually "background tasks", where the user has no awareness of any short delay.
It should be used sparingly (at least for very short periods of time) in a single threaded "User Interface" application, since it *does* make the app look like it's dead.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.