Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / September 2005

Tip: Looking for answers? Try searching our database.

Windows Service and shutdown/restart of server...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom - 29 Sep 2005 14:47 GMT
I've written a Windows Service using VB.NET, which does a
connection to a database and then runs a timer to
periodically process some data. It is running pretty well;
However, I have noticed one issue: Whenever the
workstation/server is shut down/restarted the database
connection is staying open. It is as though the Windows
Service Manager is not calling the STOP method for my
service whenever the server is shutting down. Is there
something else I need to code for (i.e. the
OnPowerShutdown) to make sure my service 'stops' whenever
the machine is shut down?

Thanks in advance.

Tom
Kevin Spencer - 29 Sep 2005 16:04 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.