473,836 Members | 1,519 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
servicecontroll er 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.Sta tus = Servicecontroll erStatus.runnin g then
ServiceName.Exe cutecommand(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 2363
If you do what you indicate and the service is not 'geared-up' to handle
that command you will get an InvalidOperatio nException, as is stated in the
documentation for the ServiceControll er.ExecuteComma nd 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******@discu ssions.microsof t.com> wrote in message
news:9D******** *************** ***********@mic rosoft.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
servicecontroll er 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.Sta tus = Servicecontroll erStatus.runnin g then
ServiceName.Exe cutecommand(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
2202
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 issue is simply getting timers to work. I have a DatabaseManager.DataManagerFacade which contains a timer. Every 6 seconds it updates stock data using an online webservice. I wrote have 2 possible startup projects to make the service work. One...
1
3457
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 going wrong. The program has been written to do the following tasks: - Select remote server - Select from two specific services
0
3946
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 - Select from two specific services - Check the status of the server
1
1199
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
4190
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 check to see if the status is in stopped or running mode. But that doesn't tell me if it is actually running. I need to know this so that if it happens I can programmatically start the same service on another machine.
3
13810
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 service run in an application pool which runs under a domain user, this domain user has permissions of accessing database and the connection to database is trusted connection. All these work well. The web application will be used in internet (not...
4
8836
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 how to get the service to exit when the worker thread has a fatal error *and* get the SCM to invoke the auto-restart configuration? The worker thread can error out while the parent thread in the server process chugs along. We can set the exit...
1
2094
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 service. I can send custom commands to start or stop or... any of the worker objects that the windows service will be hosting. What I need to do is to get some information back to the Tray Icon app or the windows form about the actual worker items...
3
2921
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 can I tell the windows service to import data from another application? - Is it possible to have a UI for the service, like a tray icon with the status of the service?
3
7061
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 run application remotely and retrieve grid and form data in some way without accessing directly to database server? Web Services is being used for this purpose I think, Which methods must be used for this ?
0
9825
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9671
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10854
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10257
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7794
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5829
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4459
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4022
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.