This cannot be done in standard C, you need to use some kind of API for a specific platform.
One popular choice is the POSIX alarm() function.
This is a "clean" asynchronous solution. Of course, you can measure and process time in other ways, but they still depend on the platform. You can use sleep() (again POSIX) to just block. If you combine this with your queries in a loop, this should work too.
unwind
source share