Service restart itself?

  • Thread starter Thread starter Matt
  • Start date Start date
M

Matt

Is there an 'easy' way to have a service stop and restart itself? I
currently have a seperate service running who's job is to watch the other
service and restart it if there is a problem... can I eliminate that one and
have the service restart itself?

Thanks,

Matt
 
Matt,
You can use ServiceController class to stop and start windows services.
Something like this

Imports System.ServiceProcess

Dim MyController As ServiceController = New ServiceController("ServiceName")

If MyController.CanStop Then
MyController.Stop()
End If

Val
 
Hi Matt,

You can configure your to restart itself if an error occurs.
You can do that from the services.msc - your service - Recovery.

Br.

Kristian F. Thomsen
 
Hi Kristian,

How does this work? Do I need to leave certain exceptions unhandled?

Unfortunately, one problem I am having is that the socket listener just
decides to not listen any longer, and throws no errors. I even have a timer
running and every few seconds it checks the state of the listener and the
state seems fine.

Thanks,

Matt
 

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

Back
Top