I would use a waitable timer. Because it will block your program while you are waiting, but if you expand your program in the future, you will have the ability to wake that thread up before the timer expires. With Sleep, your program will block for the same amount of time and this cannot be changed at runtime. Here is an example from MSDN of how to use a waitable timer.
#include #include int main()
{
HANDLE hTimer = NULL;
LARGE_INTEGER liDueTime;
liDueTime.QuadPart=-100000000;
// Create a waitable timer.
hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer");
if (!hTimer)
{
printf("CreateWaitableTimer failed (%d)\\n", GetLastError());
return 1;
}
printf("Waiting for 10 seconds...\\n");
// Set a timer to wait for 10 seconds.
if (!SetWaitableTimer(
hTimer, &liDueTime, 0, NULL, NULL, 0))
{
printf("SetWaitableTimer failed (%d)\\n", GetLastError());
return 2;
}
// Wait for the timer.
if (WaitForSingleObject(hTimer, INFINITE) != WAIT\_OBJECT\_0)
printf("WaitForSingleObject failed (%d)\\n", GetLastError());
else printf("Timer was signaled.\\n");
return 0;
}
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life!