473,395 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Windows Service Status

In searching this site, i have seen plenty of posts and answers detailing how
to check the status of a service.

Many services, however, will "hang". Their status says that are running,
but in reality the service is non-responsive.

In light of this, I am using the ExecuteCommand method of the specified
servicecontroller to "ping" teh service. In that method I pass it a command
(an arbitrary number higher than 245). My understanding is that Services
will ignore commands that they don't recognize. Such as:

If ServiceName.Status = ServicecontrollerStatus.running then
ServiceName.Executecommand(248)
end if

My thinking is that if the service is "hung" or nonresponsive, it will error
out and fall into my Try-Catch which tells me it is hung, otherwise it will
just ignore the command and continue.

Is my thinking correct in this?

Scott
--
Thanks,

Scott
Nov 21 '05 #1
1 2347
If you do what you indicate and the service is not 'geared-up' to handle
that command you will get an InvalidOperationException, as is stated in the
documentation for the ServiceController.ExecuteCommand method.

A 'well behaved' service will, when it fails internally, write appropriate
messages to the EventLog and take itself down cleanly.

As you have noticed, not all services are 'well-behaved'. Unfortunately
there isn't much you can do about this other than go to the supplier of the
service, thump the table and demand that they 'play the game'.
"SQLScott" <SQ******@discussions.microsoft.com> wrote in message
news:9D**********************************@microsof t.com...
In searching this site, i have seen plenty of posts and answers detailing
how
to check the status of a service.

Many services, however, will "hang". Their status says that are running,
but in reality the service is non-responsive.

In light of this, I am using the ExecuteCommand method of the specified
servicecontroller to "ping" teh service. In that method I pass it a
command
(an arbitrary number higher than 245). My understanding is that Services
will ignore commands that they don't recognize. Such as:

If ServiceName.Status = ServicecontrollerStatus.running then
ServiceName.Executecommand(248)
end if

My thinking is that if the service is "hung" or nonresponsive, it will
error
out and fall into my Try-Catch which tells me it is hung, otherwise it
will
just ignore the command and continue.

Is my thinking correct in this?

Scott
--
Thanks,

Scott

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nathan Kovac | last post by:
I have a feeling I am missing something simple, but I just can't find it. Perhaps someone can give me a lead on where to look. I will describe the issue then post my code to the web service. My...
1
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. I'm having trouble getting the code that I've written to work, can anyone shed some light as to where I'm...
0
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. The program I'm trying to develop needs to be able to do the following: - Select remote server -...
1
by: Przemo | last post by:
Is it possible to start or stop a windows service from ASP.NET 2.0? Some examples? thanks Przemo
4
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to...
3
by: =?Utf-8?B?RGFuZGFuIFpoYW5n?= | last post by:
Now I have a web application, a web service and a SQL Server database. The Web application will invoke the web service, the web service invokes the SQL Server stored procedure. I let the web...
4
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... Following the samples online, we implemented a windows service in .Net. Like most services, there's a worker thread actually doing stuff in the background. The problem we've run into is...
1
by: =?Utf-8?B?VzFsZDBuZTc0?= | last post by:
I need to create a Windows Service, which will be hosting a couple of worker classes, each in there own thread. I will be creating a tray Icon (Notify Icon) and a windows form to manage this...
3
by: =?Utf-8?B?RGlvZ28gQWx2ZXMgLSBTb2Z0d2FyZSBEZXZlbG9w | last post by:
Greetings, I would like to create a windows service that would expect an event from my software to import data from a device and/or to import data in scheduled times My questions are: - How...
3
by: Sylvie | last post by:
My Windows Application has two forms, one form contains a grid (lets say Stock Listing), and the other is a form of one stock, contains some edit boxes for one stock's fields.. Is it possible to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.