Groups | Blog | Home
all groups > dotnet faqs > january 2006 >

dotnet faqs : Prevent service from stopping


Ramu Nallamothu
1/11/2006 1:25:48 PM
Did you try changing the service startup type to "Manual". ?

Thanks.
Ramu



[quoted text, click to view]

Gregory Gadow
1/11/2006 2:25:55 PM
[quoted text, click to view]

Perhaps if you gave it something to do? A timing loop, something like that.
--
Gregory Gadow

ThunderMusic
1/11/2006 4:20:03 PM
Hi,
I have a service which is only a server for some objects the user can
instanciate and call.

Right now, the service starts and then stops automaticaly. The only line of
code I added is in the OnStart event and is
"RemotingConfiguration.Configure(configfile)". So I guess the service is
stopping because it has nothing better to do?

Is there a setting I can set to prevent it from stopping? will I have to
start a loop that will run until the OnStop event runs in order to keep the
service alive?

Thanks

ThunderMusic

Phil Wilson
1/11/2006 4:23:16 PM
OnStart is an "event" that gets called when your Service is initiated, to do
initialization etc. You would typically start a thread there (ThreadStart
for some method you run) that runs until some event happens, you trigger
that event in OnStop().
--
Phil Wilson [MVP Windows Installer]
----
[quoted text, click to view]

ThunderMusic
1/11/2006 4:28:55 PM
no, I want it to be automatic... I just want it to stay alive after it
starts...


[quoted text, click to view]

Igor
1/12/2006 1:11:00 PM
[quoted text, click to view]
spawn a thread or a backgroundworker in the onstart method that does the listening (
while run_flag
system.threading.thread.sleep(150)
end while
).
Onstart is only the initializer, not the worker - i.e. if you loop in onstart, you will get an error that the service did not respond in a timely fashion...

Doug Forster
1/12/2006 1:22:25 PM
Hi,

[quoted text, click to view]

No.
If you are using the default generated code for the service this should
include a call to System.ServiceProcess.ServiceBase.Run in its Main. This
keeps the service running until it is explicitly stopped.

The usual reason for a service mysteriously stopping is an exception (which
doesn't show because services don't have a UI by default).

Cheers
Doug Forster

[quoted text, click to view]

AddThis Social Bookmark Button