I have an application in C# (2.0 running on XP embedded) that is communicating with a ‘watchdog’ that is implemented as a Windows Service. When the device boots, this service typically takes some time to start. I’d like to check, from my code, if the service is running. How can I accomplish this?
Share
I guess something like this would work:
Add
System.ServiceProcessto your project references (It’s on the .NET tab).Edit: There is also a method
sc.WaitforStatus()that takes a desired status and a timeout, never used it but it may suit your needs.Edit: Once you get the status, to get the status again you will need to call
sc.Refresh()first.Reference: ServiceController object in .NET.