3

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

1 Answer 1

1

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

3
  • 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, 2010 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, 2010 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, 2010 at 14:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .