HighTechTalks DotNet Forums  

Prevent service from stopping

Dotnet FAQs microsoft.public.dotnet.faqs


Discuss Prevent service from stopping in the Dotnet FAQs forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
ThunderMusic
 
Posts: n/a

Default Prevent service from stopping - 01-11-2006 , 04:20 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



Reply With Quote
  #2  
Old   
Ramu Nallamothu
 
Posts: n/a

Default Re: Prevent service from stopping - 01-11-2006 , 04:25 PM






Did you try changing the service startup type to "Manual". ?

Thanks.
Ramu



"ThunderMusic" <NOdanlatSPAM@hotmaildotcom> wrote

Quote:
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




Reply With Quote
  #3  
Old   
ThunderMusic
 
Posts: n/a

Default Re: Prevent service from stopping - 01-11-2006 , 04:28 PM



no, I want it to be automatic... I just want it to stay alive after it
starts...


"Ramu Nallamothu" <rnallam (AT) hotmail (DOT) com> wrote

Quote:
Did you try changing the service startup type to "Manual". ?

Thanks.
Ramu



"ThunderMusic" <NOdanlatSPAM@hotmaildotcom> wrote in message
news:uCW8fTvFGHA.740 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
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






Reply With Quote
  #4  
Old   
Gregory Gadow
 
Posts: n/a

Default Re: Prevent service from stopping - 01-11-2006 , 05:25 PM



ThunderMusic wrote:

Quote:
no, I want it to be automatic... I just want it to stay alive after it
starts...
Perhaps if you gave it something to do? A timing loop, something like that.
--
Gregory Gadow




Reply With Quote
  #5  
Old   
Doug Forster
 
Posts: n/a

Default Re: Prevent service from stopping - 01-11-2006 , 07:22 PM



Hi,

Quote:
"RemotingConfiguration.Configure(configfile)". So I guess the service is
stopping because it has nothing better to do?
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

"ThunderMusic" <NOdanlatSPAM@hotmaildotcom> wrote

Quote:
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
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




Reply With Quote
  #6  
Old   
Phil Wilson
 
Posts: n/a

Default Re: Prevent service from stopping - 01-11-2006 , 07:23 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]
----
"ThunderMusic" <NOdanlatSPAM@hotmaildotcom> wrote

Quote:
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




Reply With Quote
  #7  
Old   
Igor
 
Posts: n/a

Default Re: Prevent service from stopping - 01-12-2006 , 07:11 AM



ThunderMusic wrote:
Quote:
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


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...

on onstop method set the run_flag to false and release resources.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.