HighTechTalks DotNet Forums  

s there a way to be notified when the status of a certain service has changed

Dotnet Framework (Component Services) microsoft.public.dotnet.framework.component_services


Discuss s there a way to be notified when the status of a certain service has changed in the Dotnet Framework (Component Services) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Naim Rizk
 
Posts: n/a

Default s there a way to be notified when the status of a certain service has changed - 07-31-2003 , 06:13 AM








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!

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.