hi,
I want to make an application that checks the status of a specific
service on a remote computer all the time and executes some code when
its status changes.
Can i use an addhanler to notify me when the service status has changed
or do i always have to check the status of the service continuously (in
an infinite loop)?
what's the ideal way to do this and save the maximum of
ressources...(the application might run 24 hours a day)
the code to check the status of the service is posted below.
Dim serviceName As String = "Hello-World Service"
Dim myService As System.ServiceProcess.ServiceController
dim machineName as string = "RemoteComputer"
Dim ArraySrvCtrl() As System.ServiceProcess.ServiceController
ArraySrvCtrl =
System.ServiceProcess.ServiceController.GetService s(MachineName)
Dim sc As System.ServiceProcess.ServiceController
For Each sc In ArraySrvCtrl
If sc.ServiceName.ToLower = serviceName.ToLower Then
MsgBox(sc.Status)
Exit For
End If
Next
is there a better way to get a specific service than getting all the
services and iterating throught them? it'will be too much ressource
consuming especially if i m checking the status of the service in an
infinte loop continuously.
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!