VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



WaitableTimer API

by David Drake (5 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (18 Votes)



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

Download WaitableTimer API

Download WaitableTimer API (3 KB)

WaitableTimer API Comments

No comments have been posted about WaitableTimer API. Why not be the first to post a comment about WaitableTimer API.

Post your comment

Subject:
Message:
0/1000 characters