Prevent service from stopping

Discussion in 'ASP .Net' started by ThunderMusic, Jan 11, 2006.

  1. ThunderMusic

    ThunderMusic Guest

    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
    ThunderMusic, Jan 11, 2006
    #1
    1. Advertising

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

    Thanks.
    Ramu



    "ThunderMusic" <NOdanlatSPAM@hotmaildotcom> wrote in message
    news:...
    > 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
    >
    Ramu Nallamothu, Jan 11, 2006
    #2
    1. Advertising

  3. ThunderMusic

    ThunderMusic Guest

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


    "Ramu Nallamothu" <> wrote in message
    news:%...
    > Did you try changing the service startup type to "Manual". ?
    >
    > Thanks.
    > Ramu
    >
    >
    >
    > "ThunderMusic" <NOdanlatSPAM@hotmaildotcom> wrote in message
    > news:...
    >> 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
    >>

    >
    >
    ThunderMusic, Jan 11, 2006
    #3
  4. ThunderMusic wrote:

    > 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
    Gregory Gadow, Jan 11, 2006
    #4
  5. ThunderMusic

    Doug Forster Guest

    Hi,

    > "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 in message
    news:...
    > 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
    >
    Doug Forster, Jan 12, 2006
    #5
  6. ThunderMusic

    Phil Wilson Guest

    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 in message
    news:...
    > 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, Jan 12, 2006
    #6
  7. ThunderMusic

    Igor Guest

    ThunderMusic wrote:
    > 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.
    Igor, Jan 12, 2006
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. joe
    Replies:
    1
    Views:
    2,698
    Alan Pretre
    Jul 10, 2003
  2. Replies:
    7
    Views:
    385
  3. DK
    Replies:
    6
    Views:
    2,498
    Peter Hansen
    Aug 18, 2005
  4. Paul Metzger

    Stopping Windows Service

    Paul Metzger, Mar 1, 2006, in forum: Python
    Replies:
    6
    Views:
    2,221
    Larry Bates
    Mar 3, 2006
  5. Gheorghe Postelnicu
    Replies:
    0
    Views:
    718
    Gheorghe Postelnicu
    Apr 30, 2007
Loading...

Share This Page