Originally posted by: DaveSimmons
Depends on the OS. You might be able to sleep() or in Windows you can set a timer which fires a message.
Originally posted by: EagleKeeper
Originally posted by: DaveSimmons
Depends on the OS. You might be able to sleep() or in Windows you can set a timer which fires a message.
Windows will also acknowledge Sleep from C or C++.
I believe that it may be a C standard.
" Header: Declared in Winuser.h; include Windows.h." <-- The Friendly Manual (Books Online or MSDN)Originally posted by: bigalt
edit: grr... i can't find settimer either. is there a place i'm supposed to update my windows.h file?
If you don't know the Windows event-driven model where "messages" sent to "windows" control program flow, and don't want to work through Petzold's Programming Windows to learn it, then just keeping your current polling loops might be the way to go.and if I have no idea what a window is, how would I treat that handle?
Originally posted by: DaveSimmons
" Header: Declared in Winuser.h; include Windows.h." <-- The Friendly Manual (Books Online or MSDN)Originally posted by: bigalt
edit: grr... i can't find settimer either. is there a place i'm supposed to update my windows.h file?
If you don't know the Windows event-driven model where "messages" sent to "windows" control program flow, and don't want to work through Petzold's Programming Windows to learn it, then just keeping your current polling loops might be the way to go.and if I have no idea what a window is, how would I treat that handle?
Sleep
The Sleep function suspends the execution of the current thread for a specified interval.
VOID Sleep(
DWORD dwMilliseconds // sleep time in milliseconds
);
Parameters
dwMilliseconds
Specifies the time, in milliseconds, for which to suspend execution. A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution. A value of INFINITE causes an infinite delay.
Return Values
This function does not return a value.
Remarks
A thread can relinquish the remainder of its time slice by calling this function with a sleep time of zero milliseconds.
You have to be careful when using Sleep and code that directly or indirectly creates windows. If a thread creates any windows, it must process messages. Message broadcasts are sent to all windows in the system. If you have a thread that uses Sleep with infinite delay, the system will deadlock. Two examples of code that indirectly creates windows are DDE and COM CoInitialize. Therefore, if you have a thread that creates windows, use MsgWaitForMultipleObjects or MsgWaitForMultipleObjectsEx, rather than Sleep.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.