469,623 Members | 994 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

Monitoring Service Activity

I have a windows service that in the OnStart it creates a thread and runs a
loop forever and ever, assuming the service is running. The loop stops
during the OnStop event, and everything works exactly as expected.

I also have an application that monitors that service using the
ServiceController component, and allows me to start & stop the service as
needed, as well as poll for it's current status. Still everything thus far
works and behaves as expected.

Now I want to add some functionality to the service monitoring application
to get actual useful information from the service, such as what is it
currently doing within the loop.

My idea (not sure if this is correct or not) was to create a new thread
that'll start in the service that will accept and send windows messages back
and forth between the monitoring application. The main processing loop,
everytime it's getting ready to do something would post it's current
activity/status to some variable somewhere that the other thread can pick up
and send (via SendMessage?) to the monitoring app...

Of course this is all hypothetical, assuming I can even do something like
this...

Ideas? Suggestions? Comments? Tips? Pointers??
Nov 17 '05 #1
3 2132
Any ideas or suggestions at all??

"JSheble" <js************@logicor.com> wrote in message
news:O0**************@TK2MSFTNGP10.phx.gbl...
I have a windows service that in the OnStart it creates a thread and runs a
loop forever and ever, assuming the service is running. The loop stops
during the OnStop event, and everything works exactly as expected.

I also have an application that monitors that service using the
ServiceController component, and allows me to start & stop the service as
needed, as well as poll for it's current status. Still everything thus
far works and behaves as expected.

Now I want to add some functionality to the service monitoring application
to get actual useful information from the service, such as what is it
currently doing within the loop.

My idea (not sure if this is correct or not) was to create a new thread
that'll start in the service that will accept and send windows messages
back and forth between the monitoring application. The main processing
loop, everytime it's getting ready to do something would post it's current
activity/status to some variable somewhere that the other thread can pick
up and send (via SendMessage?) to the monitoring app...

Of course this is all hypothetical, assuming I can even do something like
this...

Ideas? Suggestions? Comments? Tips? Pointers??

Nov 17 '05 #2

"JSheble" <js************@logicor.com> wrote in message
news:O0**************@TK2MSFTNGP10.phx.gbl...
I have a windows service that in the OnStart it creates a thread and runs a
loop forever and ever, assuming the service is running. The loop stops
during the OnStop event, and everything works exactly as expected.

I also have an application that monitors that service using the
ServiceController component, and allows me to start & stop the service as
needed, as well as poll for it's current status. Still everything thus
far works and behaves as expected.

Now I want to add some functionality to the service monitoring application
to get actual useful information from the service, such as what is it
currently doing within the loop.

My idea (not sure if this is correct or not) was to create a new thread
that'll start in the service that will accept and send windows messages
back and forth between the monitoring application. The main processing
loop, everytime it's getting ready to do something would post it's current
activity/status to some variable somewhere that the other thread can pick
up and send (via SendMessage?) to the monitoring app...

Of course this is all hypothetical, assuming I can even do something like
this...

Ideas? Suggestions? Comments? Tips? Pointers??


Have another service thread publishing your service state as WMI class
instances and/or events, a monitoring application can register event
listeners or query the state of the service
Both class instances and events can be produced using System.Management and
System.Management.Instrumentation, check the docs for details on event
publishing and how to implement instance providers in WMI. Note that this is
the way all MSFT services like SQL/Exchange and ASP.NET are providing
monitoring and instrumentation information.

Willy.

Nov 17 '05 #3

"JSheble" <js************@logicor.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
ok, thanx... I'll look into it... WMI Event Publishing, right?


Well, you can publish events, but IMO what you are looking for is to publish
instances of .NET classes as WMI classes. The class(es) holds the state of
the service at a certain point in time. Events can be used when a state
changes, for instance when the service is paused you can fire an event so
that the monitor is no longer required to read status instances.

Willy.

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Wally | last post: by
4 posts views Thread by johnm | last post: by
1 post views Thread by Sylesh Nair | last post: by
reply views Thread by Paul Steele | last post: by
3 posts views Thread by BC | last post: by
2 posts views Thread by bic1ster | last post: by
reply views Thread by origami.takarana | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.