Can a windowless dll have a message loop?
-
I am running Windows CE. I want to trigger a function every 30 minutes. I understand that this can be done by using timers. But a timer object needs DispatchMessage() function for TimerProc() to get called. Is it possible to provide a message loop in a windowless DLL? If yes, where should the message loop be defined? (I tried providing a message loop in the DLL but the DLL started showing strange behavior. Is it at all possible?) Windows ce does not support Timer Queues or Waitable timers. Is there any other option? Any suggestions would be highly appreciated. Thanks, Ruchika
-
I am running Windows CE. I want to trigger a function every 30 minutes. I understand that this can be done by using timers. But a timer object needs DispatchMessage() function for TimerProc() to get called. Is it possible to provide a message loop in a windowless DLL? If yes, where should the message loop be defined? (I tried providing a message loop in the DLL but the DLL started showing strange behavior. Is it at all possible?) Windows ce does not support Timer Queues or Waitable timers. Is there any other option? Any suggestions would be highly appreciated. Thanks, Ruchika
Another option would be to use a thread. Worker threads do not need a message loop and you can control their timing with equal (if not greater) accuracy. The code would look something like this:
BOOL bLoop = TRUE;
while(bLoop)
{
Sleep(30*60*1000); // 30 minutes in milliseconds// // Do your stuff here. Do not forget to set bLoop to // FALSE when you want the loop terminated. //
}
Please note that this code might not be the best for battery saving purposes.
-
Another option would be to use a thread. Worker threads do not need a message loop and you can control their timing with equal (if not greater) accuracy. The code would look something like this:
BOOL bLoop = TRUE;
while(bLoop)
{
Sleep(30*60*1000); // 30 minutes in milliseconds// // Do your stuff here. Do not forget to set bLoop to // FALSE when you want the loop terminated. //
}
Please note that this code might not be the best for battery saving purposes.
Thank you so much for the suggestion. I am leaning more towards not adding a background thread mainly becz I already have three threads in my module. So, I am thinking of modifying one of the threads that I have to wait for RETRANSMIT_TIME, do the job and again wait. Ruchika