Re: Timer not working in WinCE Service

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Why do you have a message pump?? You have no windows. You have no
messages. Create a loop with a Sleep of WaitForSingleObject call like Paul
suggested. Asking for help is not terribly useful if you're not going to
listen to the advice given.



--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com




"Rahul P. Shukla" <RahulPShukla@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:290034F3-5357-4881-8F75-D2F852C57F5F@xxxxxxxxxxxxxxxx
here is my message loop code ....

DWORD MyThread(void * f_pMainObj)
{
MSG msg; // message structure

while(GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg); // translates virtual-key codes
DispatchMessage(&msg); // dispatches message to window
}
return 0;
}

// and Timerproc
void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
{
// Doing some file logging here, to know that control has reached here
return 0;
}

I just want to know that, why timers are not working in case of Service,
but
same DLL is working when not using as service !!!!!!
any clue ..???

- Rahul


"<ctacke/>" wrote:

Show us yopur loop code. The issue must be in your code since a driver
an
an app are not terribly different under CE.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com


"Rahul P. Shukla" <RahulPShukla@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
news:2BEFA1C7-4DFB-4484-B0D5-0D6CE5D02E51@xxxxxxxxxxxxxxxx
Hello Paul,
I used a simple thread to complete my task. But for timers, as u said
there
is no message loop, So I created a simple thread which was having
message
loop to dispatch the messages. But it was not working too.
Now the same code (with timer and without any message loop) for a
simple
DLL
was working but whenever I was registering the same DLL as service, the
code
stops working. I wornder, what is the issue here.

-Rahul

"Paul G. Tobey [eMVP]" wrote:

SetTimer() uses, if I recall correctly, the application event loop to
notify
the clients that the timer has fired. Since you're in a driver and
there
is
no message loop, that's not going to work. You'll need to use
something
different. That might be a multimedia timer, if your OS has that, a
simple
WaitForSingleObject() with a timeout equal to 2000, etc.

Paul T.

"Rahul P. Shukla" <RahulPShukla@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
news:725011ED-2316-41E7-9D26-5469B6F6938F@xxxxxxxxxxxxxxxx
I am using SetTimer(NULL, NULL, 2000, (TIMERPROC) TimerProc) inside
xxx_Init,
but it seems control is not going my TimerProc.
My Timerproc is as:
void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD
dwTime)

What may be the reason that timeer is not working.

-Rahul


"Paul G. Tobey [eMVP]" wrote:

"Timer"? What call are you using?

Paul T.

"Rahul P. Shukla" <RahulPShukla@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
news:2B7CCCA4-59D4-4653-ACBE-00C41E919276@xxxxxxxxxxxxxxxx
Hi,
I am creating a Win32 service for my WinCE 4.2 based device using
eVC++. I
am using timer in that but its not working. But when I run the
same
DLL
no
as
service, it executes fine ....

What may be the problem that time is not working in service?
Please let me know if U have any idea...
Thanks,
Rahul











.



Relevant Pages

  • Re: question about thread scheduling
    ... I will try what you suggested, the reason that I didn't use the sleep method ... whatsoever to tamper with the timer tick. ... If the NN run in a different thread as the control loop ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Timer module for interpreter
    ... What I'd like to do is have a fall-back timer so that if some ... loop which is running the code. ... Presumably the flag set by the ... module and checked by the main interpreter loop would also have ...
    (comp.sys.acorn.programmer)
  • Re: Timer module for interpreter
    ... What I'd like to do is have a fall-back timer so that if some ... loop which is running the code. ... Several of my applications use SWI OS_CallAfter to set a routine to be ... intervals to allow cooperatively multi-task to continue. ...
    (comp.sys.acorn.programmer)
  • Re: How to create a synchronous call in a In-Process server
    ... I think you're going to have to use QueryUnload, but rather than a timer fired from that, I'd favor an event model where the activex component signals it is safe to unload it after a stop or unload request has been made. ... don't listen to anyone who says put a Sleep call in your DoEvents loop as that would make things worse. ... Private Sub Form1_Load ...
    (microsoft.public.vb.general.discussion)
  • Re: No return from async web service call
    ... \par Microsoft Online Support ... \par Hi Paul, ... The only problem is that when using while loop to poll the Complete status, the main UI thread will be blocked from accepting other UI message gracefully. ... No return from async web service call ...
    (microsoft.public.dotnet.framework.webservices)