Windows Service - Dies during sleep

  • Thread starter Thread starter jehugaleahsa
  • Start date Start date
J

jehugaleahsa

Hello:

I have had a program that checks LDAP to get a list of all the users
whose password will expire. I send these users an email letting them
know to change their passwords.

It had been working fine for months. Then, all of a sudden, something
changed and now the service dies unexpectedly. I wrote some code to
log what was the last step performed and it appears as though the
service dies while it is "sleeping".

Is there something on Windows that would try to kill my service? It
will usually run successfully once and then just die with an event
viewer log of "Faulting application, ..., faulting module unknown, ...

The error message is worthless and the log shows that everything ran
fine. Does anyone know what could be causing this to happen? Even
odder is the fact that is only seems to die on a production machine
and not on a test machine.

By the way, I originally wrote the service to work in a Thread.
However, in an attempt to resolve this issue, I am now using
System.Timers.Timer to do the same thing. The Thread always died
during Thread.Sleep and the Timer dies while time is passing. It is
just like something is killing my service.

Thanks,
Travis
 
Hi Travis,

Instead of using System.Timers.Timer, try using System.Threading.Timer. This
timer is a much better fit for usage is environments like a windows
serverice. It should require very few changes to your code, and might solve
your problem.

Bennie Haelen ([email protected])
 
Hi,

Are you catching AppDomain.UnhandledException ? Maybe you are getting an
exceptio somewhere.

Also make sure to wrap your code in a try/catch
 
Hi,

Are you catching AppDomain.UnhandledException ? Maybe you are getting an
exceptio somewhere.

Also make sure to wrap your code in a try/catch












- Show quoted text -

The entire application is wrapped in a giant try/catch and it catches
a generic Exception. However, if an error did occur, than I would see
it in my event viewer. However, my log shows that everything completed
successfully. So, I can say with utmost certainty that is not
something in my code that causing the service to die.

I am wondering if there is some sort of issue on the server . . . and
it doesn't help that the service dies at seemingly random times -
usually within 5 minutes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top