SetTimer() Should Not Be Used in Console ApplicationsLast reviewed: November 2, 1995Article ID: Q102482 |
The information in this article applies to:
SUMMARYSetTimer() was not designed to be used with a console application because it requires a message loop to dispatch the timer signal to the timer procedure. In a console application, this behavior can be easily emulated with a thread that is set to wait on an event.
MORE INFORMATIONIn Windows NT 3.1, SetTimer() can work within a console application, but it requires a thread in a loop calling GetMessage() and DispatchMessage(). For example,
while (1) { GetMessage(); DispatchMessage(); }Because this requires a thread looping, there is no real advantage to adding a timer to a console application over using a thread waiting on an event. Another option is to use a multimedia timer, which does not require a message loop and has a higher resolution. In Windows NT 3.5, the resolution can be set to 1 msec using timeBeginPeriod(). See the help for timeSetEvent() and the Multimedia overview. Any application using Multimedia calls must include MMSYSTEM.H, and must link with WINMM.LIB.
|
Additional reference words: 3.10 3.50 3.51 4.00 95
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |