Have you implemented an OnShutDown event handler for the service? If you do,
you should set CanShutDown to true as well.

Signature
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Big things are made up of
lots of little things.
> I've written a Windows Service using VB.NET, which does a
> connection to a database and then runs a timer to
[quoted text clipped - 11 lines]
>
> Tom
Tom - 29 Sep 2005 18:00 GMT
> Have you implemented an OnShutDown event handler for the
> service? If you do, you should set CanShutDown to true as
> well.
Ah, stupid me, that is what I am missing. Duh, didn't code
the OnShutdown event...
Thanks!
Tom - 29 Sep 2005 21:46 GMT
> Have you implemented an OnShutDown event handler for the
> service? If you do, you should set CanShutDown to true as
> well.
Kevin: I take my previous message back... I coded the
appropriate stuff into the OnShutdown event. The last
statement I have in there is one to write to the log that
the service was successfully shut down. I even have the
CanShutdown = True up in the constructor.
However, if I restart or shutdown my server (and the
service is running) it still doesn't seem to run the
OnShutdown method. I know this to be true because (1) I
never get the shutdown message in the application log, and
(2) My database connection is still left open!
Any ideas as to what else I need to look or code for?
Thanks.
Tom
Kevin Spencer - 29 Sep 2005 23:49 GMT
I'm pretty much out of ideas at this point. You could try writing a
deconstructor or Dispose method.

Signature
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Big things are made up of
lots of little things.
>> Have you implemented an OnShutDown event handler for the
>> service? If you do, you should set CanShutDown to true as
[quoted text clipped - 16 lines]
>
> Tom
Willy Denoyette [MVP] - 30 Sep 2005 15:29 GMT
Are you sure the eventlog service is still running when your OnShutdown
handler runs?
Better write to a logfile.
Willy.
>> Have you implemented an OnShutDown event handler for the
>> service? If you do, you should set CanShutDown to true as
[quoted text clipped - 16 lines]
>
> Tom