Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have written an application which runs as a Windows service. Within the service we have a timer that fires every 15 seconds and connects to a ODBC datasource (e.g. MySql, SqlServer), processes queries, and disconnects. We always assume the connection exists and use exception handling in our code when it can't be made.

When the connection to the database is sporadic (i.e. poor network connection, or simply the database is off), I have seen that our service will sometimes get turned off by Windows at arbitrary points.

So my question is: does Windows have some sort of mechanism to halt services if it detects it is continuously making failed requests and throwing exceptions? (in our case the unsuccessful attempts to connect to the database). Almost as if to say "Ok - you have been making these requests every 15 seconds and it is consuming resources; therefore I am going to shut you off!

Our service always tries to make a connection, and if it can't we have the

share|improve this question
up vote 1 down vote accepted

If your app throws an unhandled exception, Windows will "stop" the service.

share|improve this answer
I do believe we are "handling" exceptions properly. Will it stop immediately on the first unhandled exception? Our logs indicate the pattern can go on for many minutes if not hours and then halt. Which makes me think that perhaps we have a memory leak in our exception handling. – M Schenkel Jul 21 '10 at 14:17
It stops on crash. Unhandled exception = crash. Restart CAN be set up as servie parameter, IIRC, but the instance WILL crash. – TomTom Jul 21 '10 at 14:27
@M, Yeah if there's any sort of unhandled exception it will stop immediately. If it's very inconsistent it could be a race condition; those tend to creep into the less used error handling code in my experience. – Chris S Jul 21 '10 at 14:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.