Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>That's not your way, <code>SetTimer</code> is based on Windows messages system and will not work in console app <em>just from box</em>. You will need to create message pumping loop manually and do several other staff that is hardly met with console app structure and control flow.</p> <p>You could enjoy <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms687012%28v=vs.85%29.aspx">Waitable Timers objects</a> instead. They are designed specially to be used with threads as sync objects.</p> <p>Usage example:</p> <pre><code>#define _WIN32_WINNT 0x0500 #include &lt;windows.h&gt; #include &lt;stdio.h&gt; int main() { HANDLE hTimer = NULL; LARGE_INTEGER liDueTime; liDueTime.QuadPart=-100000000; // Create a waitable timer. hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer"); if (NULL == 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, &amp;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; } </code></pre> <p>See also nice article observing Windows timers: <a href="http://www.codeproject.com/Articles/1236/Timers-Tutorial">http://www.codeproject.com/Articles/1236/Timers-Tutorial</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload