473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Windows Services shutdown order

I've written a Windows Service to send e-mails on events like OnStart,
OnStop, OnShutDown using System.Web.Mail. It works for everything but
OnShutdown. My guess is that for OnShutDown, once my send mail code is
executed, other necessary Windows Services have been terminated before
it can actually send the mail. I've updated my
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es registry
DependOnService value including SMPTSVC and others. My hope is that the
services will shut-down in reverse order from start-up; I haven't had
any luck with this.

My Questions:
Do Windows Services (Windows 2000) shutdown in the reverse order from
which they start-up?

If so, any idea's as to which service I should include as a dependency?

If not, is there anyway I can ensure my Windows Service is
the first to shutdown?

Thanks,

~Bill

________________________
Bill Sonia
Achaia Solutions, Inc
www.achaiasolutions.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
8 4148
Hmmm,

Dunno about shutdown order - last service I wrote was for
NT 4.0 in C++. Are you sure you're getting notified when
you shutudown? What does the
ServiceController.CanShutdown property return?

--Richard

-----Original Message-----
I've written a Windows Service to send e-mails on events like OnStart,OnStop, OnShutDown using System.Web.Mail. It works for everything butOnShutdown. My guess is that for OnShutDown, once my send mail code isexecuted, other necessary Windows Services have been terminated beforeit can actually send the mail. I've updated my
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servi ces registryDependOnService value including SMPTSVC and others. My hope is that theservices will shut-down in reverse order from start-up; I haven't hadany luck with this.

My Questions:
Do Windows Services (Windows 2000) shutdown in the reverse order fromwhich they start-up?

If so, any idea's as to which service I should include as a dependency?
If not, is there anyway I can ensure my Windows Service isthe first to shutdown?

Thanks,

~Bill

________________________
Bill Sonia
Achaia Solutions, Inc
www.achaiasolutions.com

*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
.

Nov 15 '05 #2

Hi Bill,

I think your stmp server is on the same machine as your windows service.
If you use the smtp server on other machine, all will go well.(I have tried
this)

I think you can make 2 service, A depends on B, all write log to the Event
Log in ShutDown event. Then you can check the log order in the Event Viewer
if the dependency applies on shutting down.

Because sending mail through smtp is a long time process, I think even if
your dependency take effect the sending process may fail.
So I think you should use the smtp on other machine.

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: Bill Sonia <bi*******@achaiasolutions.com>
| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| Subject: Windows Services shutdown order
| Mime-Version: 1.0
| Content-Type: text/plain; charset="us-ascii"
| Content-Transfer-Encoding: 7bit
| Message-ID: <Ov**************@TK2MSFTNGP09.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Date: Mon, 20 Oct 2003 10:11:15 -0700
| NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
| Lines: 1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:192632
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| I've written a Windows Service to send e-mails on events like OnStart,
| OnStop, OnShutDown using System.Web.Mail. It works for everything but
| OnShutdown. My guess is that for OnShutDown, once my send mail code is
| executed, other necessary Windows Services have been terminated before
| it can actually send the mail. I've updated my
| HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es registry
| DependOnService value including SMPTSVC and others. My hope is that the
| services will shut-down in reverse order from start-up; I haven't had
| any luck with this.
|
| My Questions:
| Do Windows Services (Windows 2000) shutdown in the reverse order from
| which they start-up?
|
| If so, any idea's as to which service I should include as a dependency?
|
| If not, is there anyway I can ensure my Windows Service is
| the first to shutdown?
|
| Thanks,
|
| ~Bill
|
| ________________________
| Bill Sonia
| Achaia Solutions, Inc
| www.achaiasolutions.com
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!
|

Nov 15 '05 #3
My smtp server is on another machine. Can you think of a
particular service that I should ad a dependecy to?
-----Original Message-----

Hi Bill,

I think your stmp server is on the same machine as your windows service.If you use the smtp server on other machine, all will go well.(I have triedthis)

I think you can make 2 service, A depends on B, all write log to the EventLog in ShutDown event. Then you can check the log order in the Event Viewerif the dependency applies on shutting down.

Because sending mail through smtp is a long time process, I think even ifyour dependency take effect the sending process may fail.
So I think you should use the smtp on other machine.

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
| From: Bill Sonia <bi*******@achaiasolutions.com>
| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| Subject: Windows Services shutdown order
| Mime-Version: 1.0
| Content-Type: text/plain; charset="us-ascii"
| Content-Transfer-Encoding: 7bit
| Message-ID: <Ov**************@TK2MSFTNGP09.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Date: Mon, 20 Oct 2003 10:11:15 -0700
| NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133| Lines: 1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl! TK2MSFTNGP09.phx.gbl| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:192632| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| I've written a Windows Service to send e-mails on events like OnStart,| OnStop, OnShutDown using System.Web.Mail. It works for everything but| OnShutdown. My guess is that for OnShutDown, once my send mail code is| executed, other necessary Windows Services have been terminated before| it can actually send the mail. I've updated my
| HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es registry| DependOnService value including SMPTSVC and others. My hope is that the| services will shut-down in reverse order from start-up; I haven't had| any luck with this.
|
| My Questions:
| Do Windows Services (Windows 2000) shutdown in the reverse order from| which they start-up?
|
| If so, any idea's as to which service I should include as a dependency?|
| If not, is there anyway I can ensure my Windows Service is| the first to shutdown?
|
| Thanks,
|
| ~Bill
|
| ________________________
| Bill Sonia
| Achaia Solutions, Inc
| www.achaiasolutions.com
|
| *** Sent via Developersdex http://www.developersdex.com ***| Don't just participate in USENET...get rewarded for it!
|

.

Nov 15 '05 #4

Hi Bill,

I have tried to send mail in Shutdown event, it works well, and my smtp
server is not on the same machine with the application.
As you said your smtp server is no another machine, I think you should not
get any trouble of sending mail in shutdown event.

I think you can create a tmp file on disk in shutdown event, then you can
affirm your shutdown event is called corrently.
Something like this:
protected override void OnShutdown()
{
FileStream f=File.Create("D:\\onshutdown.txt");
base.OnShutdown ();
}

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Bill Sonia" <bi*******@achaiasolutions.com>
| Sender: "Bill Sonia" <bi*******@achaiasolutions.com>
| References: <Ov**************@TK2MSFTNGP09.phx.gbl>
<H9**************@cpmsftngxa06.phx.gbl>
| Subject: RE: Windows Services shutdown order
| Date: Tue, 21 Oct 2003 07:09:53 -0700
| Lines: 97
| Message-ID: <0c****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOX3P+0rz/7d7qaRr6m4jMwxGy8Ng==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:192876
| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| My smtp server is on another machine. Can you think of a
| particular service that I should ad a dependecy to?
|
| >-----Original Message-----
| >
| >Hi Bill,
| >
| >I think your stmp server is on the same machine as your
| windows service.
| >If you use the smtp server on other machine, all will go
| well.(I have tried
| >this)
| >
| >I think you can make 2 service, A depends on B, all write
| log to the Event
| >Log in ShutDown event. Then you can check the log order
| in the Event Viewer
| >if the dependency applies on shutting down.
| >
| >Because sending mail through smtp is a long time process,
| I think even if
| >your dependency take effect the sending process may fail.
| >So I think you should use the smtp on other machine.
| >
| >Hope this helps,
| >
| >Best regards,
| >Jeffrey Tan
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
| >--------------------
| >| From: Bill Sonia <bi*******@achaiasolutions.com>
| >| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| >| Subject: Windows Services shutdown order
| >| Mime-Version: 1.0
| >| Content-Type: text/plain; charset="us-ascii"
| >| Content-Transfer-Encoding: 7bit
| >| Message-ID: <Ov**************@TK2MSFTNGP09.phx.gbl>
| >| Newsgroups: microsoft.public.dotnet.languages.csharp
| >| Date: Mon, 20 Oct 2003 10:11:15 -0700
| >| NNTP-Posting-Host: actionjackson133.dsl.frii.net
| 216.17.147.133
| >| Lines: 1
| >| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!
| TK2MSFTNGP09.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.languages.csharp:192632
| >| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| >|
| >| I've written a Windows Service to send e-mails on
| events like OnStart,
| >| OnStop, OnShutDown using System.Web.Mail. It works for
| everything but
| >| OnShutdown. My guess is that for OnShutDown, once my
| send mail code is
| >| executed, other necessary Windows Services have been
| terminated before
| >| it can actually send the mail. I've updated my
| >| HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es
| registry
| >| DependOnService value including SMPTSVC and others. My
| hope is that the
| >| services will shut-down in reverse order from start-up;
| I haven't had
| >| any luck with this.
| >|
| >| My Questions:
| >| Do Windows Services (Windows 2000) shutdown in the
| reverse order from
| >| which they start-up?
| >|
| >| If so, any idea's as to which service I should include
| as a dependency?
| >|
| >| If not, is there anyway I can ensure my Windows Service
| is
| >| the first to shutdown?
| >|
| >| Thanks,
| >|
| >| ~Bill
| >|
| >| ________________________
| >| Bill Sonia
| >| Achaia Solutions, Inc
| >| www.achaiasolutions.com
| >|
| >| *** Sent via Developersdex http://www.developersdex.com
| ***
| >| Don't just participate in USENET...get rewarded for it!
| >|
| >
| >.
| >
|

Nov 15 '05 #5
Thanks for your help. I'll give that a try

~Bill
-----Original Message-----

Hi Bill,

I have tried to send mail in Shutdown event, it works well, and my smtpserver is not on the same machine with the application.
As you said your smtp server is no another machine, I think you should notget any trouble of sending mail in shutdown event.

I think you can create a tmp file on disk in shutdown event, then you canaffirm your shutdown event is called corrently.
Something like this:
protected override void OnShutdown()
{
FileStream f=File.Create("D:\\onshutdown.txt");
base.OnShutdown ();
}

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------
| Content-Class: urn:content-classes:message
| From: "Bill Sonia" <bi*******@achaiasolutions.com>
| Sender: "Bill Sonia" <bi*******@achaiasolutions.com>
| References: <Ov**************@TK2MSFTNGP09.phx.gbl>
<H9**************@cpmsftngxa06.phx.gbl>
| Subject: RE: Windows Services shutdown order
| Date: Tue, 21 Oct 2003 07:09:53 -0700
| Lines: 97
| Message-ID: <0c****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOX3P+0rz/7d7qaRr6m4jMwxGy8Ng==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:192876| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| My smtp server is on another machine. Can you think of a| particular service that I should ad a dependecy to?
|
| >-----Original Message-----
| >
| >Hi Bill,
| >
| >I think your stmp server is on the same machine as your| windows service.
| >If you use the smtp server on other machine, all will go| well.(I have tried
| >this)
| >
| >I think you can make 2 service, A depends on B, all write| log to the Event
| >Log in ShutDown event. Then you can check the log order| in the Event Viewer
| >if the dependency applies on shutting down.
| >
| >Because sending mail through smtp is a long time process,| I think even if
| >your dependency take effect the sending process may fail.| >So I think you should use the smtp on other machine.
| >
| >Hope this helps,
| >
| >Best regards,
| >Jeffrey Tan
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >This posting is provided "as is" with no warranties and| confers no rights.
| >
| >--------------------
| >| From: Bill Sonia <bi*******@achaiasolutions.com>
| >| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| >| Subject: Windows Services shutdown order
| >| Mime-Version: 1.0
| >| Content-Type: text/plain; charset="us-ascii"
| >| Content-Transfer-Encoding: 7bit
| >| Message-ID: <Ov**************@TK2MSFTNGP09.phx.gbl>
| >| Newsgroups: microsoft.public.dotnet.languages.csharp
| >| Date: Mon, 20 Oct 2003 10:11:15 -0700
| >| NNTP-Posting-Host: actionjackson133.dsl.frii.net
| 216.17.147.133
| >| Lines: 1
| >| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!
| TK2MSFTNGP09.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.languages.csharp:192632
| >| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| >|
| >| I've written a Windows Service to send e-mails on
| events like OnStart,
| >| OnStop, OnShutDown using System.Web.Mail. It works for| everything but
| >| OnShutdown. My guess is that for OnShutDown, once my| send mail code is
| >| executed, other necessary Windows Services have been
| terminated before
| >| it can actually send the mail. I've updated my
| >| HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es
| registry
| >| DependOnService value including SMPTSVC and others. My| hope is that the
| >| services will shut-down in reverse order from start- up;| I haven't had
| >| any luck with this.
| >|
| >| My Questions:
| >| Do Windows Services (Windows 2000) shutdown in the
| reverse order from
| >| which they start-up?
| >|
| >| If so, any idea's as to which service I should include| as a dependency?
| >|
| >| If not, is there anyway I can ensure my Windows Service| is
| >| the first to shutdown?
| >|
| >| Thanks,
| >|
| >| ~Bill
| >|
| >| ________________________
| >| Bill Sonia
| >| Achaia Solutions, Inc
| >| www.achaiasolutions.com
| >|
| >| *** Sent via Developersdex http://www.developersdex.com| ***
| >| Don't just participate in USENET...get rewarded for it!| >|
| >
| >.
| >
|

.

Nov 15 '05 #6

Hi Bill,

Is your problem resolved?
If you have any question, please feel free to let me know.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Bill" <an*******@discussions.microsoft.com>
| Sender: "Bill" <an*******@discussions.microsoft.com>
| References: <Ov**************@TK2MSFTNGP09.phx.gbl>
<H9**************@cpmsftngxa06.phx.gbl>
<0c****************************@phx.gbl>
<K3**************@cpmsftngxa06.phx.gbl>
| Subject: RE: Windows Services shutdown order
| Date: Wed, 22 Oct 2003 06:22:44 -0700
| Lines: 173
| Message-ID: <05****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOYn5O5V0KNMcT2QbWI+w2WP032tw==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:193156
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Thanks for your help. I'll give that a try
|
| ~Bill
|
| >-----Original Message-----
| >
| >Hi Bill,
| >
| >I have tried to send mail in Shutdown event, it works
| well, and my smtp
| >server is not on the same machine with the application.
| >As you said your smtp server is no another machine, I
| think you should not
| >get any trouble of sending mail in shutdown event.
| >
| >I think you can create a tmp file on disk in shutdown
| event, then you can
| >affirm your shutdown event is called corrently.
| >Something like this:
| >protected override void OnShutdown()
| >{
| > FileStream f=File.Create("D:\\onshutdown.txt");
| > base.OnShutdown ();
| >}
| >
| >Best regards,
| >Jeffrey Tan
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: "Bill Sonia" <bi*******@achaiasolutions.com>
| >| Sender: "Bill Sonia" <bi*******@achaiasolutions.com>
| >| References: <Ov**************@TK2MSFTNGP09.phx.gbl>
| ><H9**************@cpmsftngxa06.phx.gbl>
| >| Subject: RE: Windows Services shutdown order
| >| Date: Tue, 21 Oct 2003 07:09:53 -0700
| >| Lines: 97
| >| Message-ID: <0c****************************@phx.gbl>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| >| Thread-Index: AcOX3P+0rz/7d7qaRr6m4jMwxGy8Ng==
| >| Newsgroups: microsoft.public.dotnet.languages.csharp
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.languages.csharp:192876
| >| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| >| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| >|
| >| My smtp server is on another machine. Can you think of
| a
| >| particular service that I should ad a dependecy to?
| >|
| >| >-----Original Message-----
| >| >
| >| >Hi Bill,
| >| >
| >| >I think your stmp server is on the same machine as
| your
| >| windows service.
| >| >If you use the smtp server on other machine, all will
| go
| >| well.(I have tried
| >| >this)
| >| >
| >| >I think you can make 2 service, A depends on B, all
| write
| >| log to the Event
| >| >Log in ShutDown event. Then you can check the log
| order
| >| in the Event Viewer
| >| >if the dependency applies on shutting down.
| >| >
| >| >Because sending mail through smtp is a long time
| process,
| >| I think even if
| >| >your dependency take effect the sending process may
| fail.
| >| >So I think you should use the smtp on other machine.
| >| >
| >| >Hope this helps,
| >| >
| >| >Best regards,
| >| >Jeffrey Tan
| >| >Microsoft Online Partner Support
| >| >Get Secure! - www.microsoft.com/security
| >| >This posting is provided "as is" with no warranties
| and
| >| confers no rights.
| >| >
| >| >--------------------
| >| >| From: Bill Sonia <bi*******@achaiasolutions.com>
| >| >| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| >| >| Subject: Windows Services shutdown order
| >| >| Mime-Version: 1.0
| >| >| Content-Type: text/plain; charset="us-ascii"
| >| >| Content-Transfer-Encoding: 7bit
| >| >| Message-ID: <Ov**************@TK2MSFTNGP09.phx.gbl>
| >| >| Newsgroups: microsoft.public.dotnet.languages.csharp
| >| >| Date: Mon, 20 Oct 2003 10:11:15 -0700
| >| >| NNTP-Posting-Host: actionjackson133.dsl.frii.net
| >| 216.17.147.133
| >| >| Lines: 1
| >| >| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!
| >| TK2MSFTNGP09.phx.gbl
| >| >| Xref: cpmsftngxa06.phx.gbl
| >| microsoft.public.dotnet.languages.csharp:192632
| >| >| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| >| >|
| >| >| I've written a Windows Service to send e-mails on
| >| events like OnStart,
| >| >| OnStop, OnShutDown using System.Web.Mail. It works
| for
| >| everything but
| >| >| OnShutdown. My guess is that for OnShutDown, once
| my
| >| send mail code is
| >| >| executed, other necessary Windows Services have been
| >| terminated before
| >| >| it can actually send the mail. I've updated my
| >| >| HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es
| >| registry
| >| >| DependOnService value including SMPTSVC and others.
| My
| >| hope is that the
| >| >| services will shut-down in reverse order from start-
| up;
| >| I haven't had
| >| >| any luck with this.
| >| >|
| >| >| My Questions:
| >| >| Do Windows Services (Windows 2000) shutdown in the
| >| reverse order from
| >| >| which they start-up?
| >| >|
| >| >| If so, any idea's as to which service I should
| include
| >| as a dependency?
| >| >|
| >| >| If not, is there anyway I can ensure my Windows
| Service
| >| is
| >| >| the first to shutdown?
| >| >|
| >| >| Thanks,
| >| >|
| >| >| ~Bill
| >| >|
| >| >| ________________________
| >| >| Bill Sonia
| >| >| Achaia Solutions, Inc
| >| >| www.achaiasolutions.com
| >| >|
| >| >| *** Sent via Developersdex
| http://www.developersdex.com
| >| ***
| >| >| Don't just participate in USENET...get rewarded for
| it!
| >| >|
| >| >
| >| >.
| >| >
| >|
| >
| >.
| >
|

Nov 15 '05 #7
Thanks for your interest. As it turns out I was headed down the wrong
road. My process does 2 things, first it writes to the event log and
second it sends the e-mail. Once I added a try catch around each
portion, it did send the mail.

i.e.
public void HandleEvent()
{
try
{
EventLog.WriteEntry(,,,)
}
catch { }

try
{
//My send mail routine
mySmtp.SendMail()
}
catch { }
}

The EventLog.WriteEntry worked onStart, onStop, onPause, etc... but
would error onShutDown. Once that was handled, the mail worked. I can
and will live without the event log on shut down but ideally I would
would like to get my app to write to the event log before the system
shuts down. Sql Server does it.

Thanks again for your help.

________________________
Bill Sonia
Achaia Solutions, Inc
www.achaiasolutions.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #8

Hi Bill,

Thanks for your feedback.
I am glad your program finally works. I can reproduce your eventlog
problem, it is because the eventlog service was shutdown before your
windows service.
I have tried to set our windows service depend on the eventlog service, but
always generates error. May be you can try to set the dependency in your
machine.

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: Bill Sonia <bi*******@achaiasolutions.com>
| References: <hA**************@cpmsftngxa06.phx.gbl>
| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| Subject: RE: Windows Services shutdown order
| Mime-Version: 1.0
| Content-Type: text/plain; charset="us-ascii"
| Content-Transfer-Encoding: 7bit
| Message-ID: <eR**************@TK2MSFTNGP09.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Date: Tue, 04 Nov 2003 07:17:43 -0800
| NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
| Lines: 1
| Path:
cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!cpmsftng xa10.phx.gbl!TK2MSFTNGXA05
phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:196608
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Thanks for your interest. As it turns out I was headed down the wrong
| road. My process does 2 things, first it writes to the event log and
| second it sends the e-mail. Once I added a try catch around each
| portion, it did send the mail.
|
| i.e.
| public void HandleEvent()
| {
| try
| {
| EventLog.WriteEntry(,,,)
| }
| catch { }
|
| try
| {
| //My send mail routine
| mySmtp.SendMail()
| }
| catch { }
| }
|
| The EventLog.WriteEntry worked onStart, onStop, onPause, etc... but
| would error onShutDown. Once that was handled, the mail worked. I can
| and will live without the event log on shut down but ideally I would
| would like to get my app to write to the event log before the system
| shuts down. Sql Server does it.
|
| Thanks again for your help.
|
| ________________________
| Bill Sonia
| Achaia Solutions, Inc
| www.achaiasolutions.com
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!
|

Nov 15 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Austin | last post by:
I wrote a program running on windows. I put the link of the program in "Start up" folder and let it executed minimized. Every time when I open the computer, my program will be running in system...
4
by: Bill Sonia | last post by:
I'm written a Windows Service to send e-mails on events like OnStart, OnStop, OnShutDown using System.Web.Mail. It works for everything but OnShutdown. My guess is that once my send mail code is...
6
by: carbon_dragon | last post by:
Ok, so here is the problem. I'm working on a headless server program implemented as a .NET C# Console project. There is a UPS mounted to this server (though not a windows compliant UPS). I can only...
2
by: Peter Meinl | last post by:
Restarting Windows seems not to fire the OnShutdown event in the Windows Service. Does not work on Windows XP SP2 and not on Windows 2003 Server SP1. OnStart and OnStop do work fine. Steps...
0
by: Stefan Krah | last post by:
Hello, I'm trying to run a Python script as a Windows service with a defined shutdown. The script (enigma-client.py) handles the communications with the server in a distributed computing effort...
4
by: Markus Stoeger | last post by:
Hi, I have a problem with Application.Run() when Windows is shutting down. Please have a look at the copy&paste example program below. The application has no forms. It has only got a notify...
0
by: Varan | last post by:
hai, now we are using batch file for take backup at time of start services and stop services. we need option for take database backup at time 1. System Start ...
0
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: List of autostart locations Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list all the autostart locations for windows? Ans: Here is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.