468,512 Members | 948 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

SleepEx problem

SleepEx suspends the current thread until the specified condition is
met. I expected the execution to resume when occurs the timeout happens
in my following example.

At the expiry of the timer it is calling "lpFnToCompletionRoutine" as
expected, but it is not printing Count in the while loop. Can anyone
explain why?


static void APIENTRY lpFnToCompletionRoutine (LPVOID lpCount,
DWORD dwTimerLowValue,
DWORD dwTimerHighValue)
{
*(LPWORD) lpCount = *(LPWORD) lpCount + 1;

}

void OmciAdapter::adapterMain()
{

/* STEPS to DO: */

//1. set the timer for every 100 milli secs to check for any OMCI
timeouts

HANDLE hTimer;
LARGE_INTEGER DueTime;
DWORD Count = 0;
const int unitsPerSecond=10*1000*1000; // 100 nano seconds
DueTime.QuadPart = -(10000 * 10000);
hTimer = CreateWaitableTimer(NULL, FALSE, "WaitableTimer");

if (NULL == hTimer)
{
printf("CreateWaitableTimer failed (%d)\n", GetLastError());
return;
}

printf("Waiting for 10 seconds...\n");

// Set a timer to wait for 10 seconds.
if (!SetWaitableTimer(hTimer, &DueTime, 10000,
lpFnToCompletionRoutine, &Count, FALSE))
{
printf("SetWaitableTimer failed (%d)\n", GetLastError());
return;
}

while (1)
{
printf ("Count = %d \n", Count);
SleepEx(INFINITE, TRUE);
}

.................

.................

.................

.................
}

Sep 6 '06 #1
1 5365
NewToCPP wrote:
SleepEx suspends the current thread until the specified condition is
met. I expected the execution to resume when occurs the timeout
happens in my following example.

At the expiry of the timer it is calling "lpFnToCompletionRoutine" as
expected, but it is not printing Count in the while loop. Can anyone
explain why?
[...]
Somebody in the newsgroup that deals with those functions and their
semantics should be able to. I can only speculate that your timers
are not running in a separate thread, and as such are probably just
as well suspended by your SleepEx. But your question is OS-specific
and as such is off-topic here. The list of suggested newsgroups is
in the FAQ.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Sep 6 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Bruce Davis | last post: by
11 posts views Thread by Kostatus | last post: by
9 posts views Thread by Sudesh Sawant | last post: by
117 posts views Thread by Peter Olcott | last post: by
28 posts views Thread by Jon Davis | last post: by
6 posts views Thread by Ammar | last post: by
2 posts views Thread by Mike Collins | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.