Mantaining a Windows Service

G

Guest

Hi,
I've been trying to write a Windows Service that handles specific events.
However, when I start it, it is immediately stopped, since it is idle when
none of the events are triggered. And when it's stopped, it can't handle the
events. How can I keep it running?
Reuben.
 
J

John Bailo

while(true)
Hi,
I've been trying to write a Windows Service that handles specific events.
However, when I start it, it is immediately stopped, since it is idle when
none of the events are triggered. And when it's stopped, it can't handle
the events. How can I keep it running?
Reuben.
 
G

Guest

When running a service a message loop is started. This means that a service
can go idle without exiting just like a normal window. If you create a
windows service from scratch from VS.net and run it, it will not exit even
though there is no work for it to do. So my guess is that there is something
wrong with your code so that your service crashes after start-up. Did you
check the event log? Putting in an infinite loop sounds like a bad idea.

Regards, Jakob.
 
R

Richard Grimes

Jakob said:
When running a service a message loop is started. This means that a
service can go idle without exiting just like a normal window. If
you create a windows service from scratch from VS.net and run it, it
will not exit even though there is no work for it to do. So my guess
is that there is something wrong with your code so that your service
crashes after start-up. Did you check the event log? Putting in an
infinite loop sounds like a bad idea.

I agree. The OP does not say how clients talk to this service, is it
through some kind of IPC? If so, have you got a problem in that
listening mechanism?

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top