VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

WaitableTimer API

David Drake  (5 Submissions)   Miscellaneous   Visual Basic 3.0   Intermediate   Wed 3rd February 2021



WaitableTimer API

This demo demonstrates how to use the WaitableTimer API in Windows. A WaitableTimer is very similar to the Sleep API. You can use this API to pause your application for a set amount of time, without taking up any CPU cycles. The benefit of a WaitableTimer over the Sleep API is that WaitableTimers allow your application to still receive events during the wait, while the Sleep command will freeze your app, queuing all events until the sleep interval has expired.


Demo

This demo shows you the difference between a 5 second wait using the Sleep API compared with a WaitableTimer. You will notice that while sleeping your form will not respond to any events, such as minimizing the form or re-painting if the form gets covered by another window. While using a WaitableTimer, the app remains completely responsive to all these Windows events!


Finally, this demo provides an easy to use class called clsWaitableTimer, which completely encapsulates the WaitableTimer API. All you will need to do to take advantage of this API is to call the method Wait, passing in the number of milliseconds you want to wait.


Enjoy and don't forget to vote!

Rate WaitableTimer API (18(18 Vote))

Download WaitableTimer API

WaitableTimer API Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters