0

I am using ServiceController to get the list of services and its status.

Below is the sample code:

var scServices = ServiceController.GetServices(machineIPOrName).ToList();
var scservice = scServices.FirstOrDefault(i => i.ServiceName.ToUpper().Equals(serviceName.ToUpper()));

Currently it returns if the service is Running, Stopped, StartPending, StopPending , Paused etc. But sometimes even though the service is Running. It will be in a hung up/ struck state, it will not be doing its job. How do i identify if the service is struck or in hunged state ?

1 Answers1

0

If you don't know what the service should be doing, there is no way to check if the service is actually doing it's job. In case you implemented the service yourself, then you could implement some kind of interface to check if it is actually running and not in some kind of halted/endless loop state.

RuudSieb
  • 523
  • 5
  • 13
  • I am building a health monitor service which will monitor all the services in production environment. Sometimes though a windows service is running state it will be unresponsive / hung. On Restart of the service things start working properly. – Santosh-Sidd Oct 25 '16 at 08:02