Re: Windows service shutdown
- From: "Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Fri, 10 Oct 2008 10:50:19 -0700
On Fri, 10 Oct 2008 08:54:55 -0700, tshad <tfs@xxxxxxxxxxxxxx> wrote:
[...]
What I don't know is what is the duration of time that a service has to
shutdown before it gets that message, or is there a setting somewhere where
you can set it?
Rather than worrying about that specific duration, you should just fix the service so that it doesn't become unresponsive while it's sleeping (why you feel it necessary for it to sleep "for about 10-20 minutes" is hard to understand too, but for the moment let's assume that's actually necessary even though it doesn't seem quite right).
From your description (it's impossible to know for sure without a concise-but-complete code sample) in the thread that would normally process messages for the service, you are calling something like Thread.Sleep() with some long value. That, of course, causes the server to fail to respond to _any_ message.
Instead of blocking that thread, you should simply be setting some state variable that indicates that the service is in its "sleeping" state. Any requests that come in while that flag is set can be ignored, rejected, etc. as appropriate but you would still respond appropriately to shutdown requests. At the same time that you set the flag, start a timer that will clear the flag when the timer period has elapsed.
In that way, you will leave your service responsive, and it can even shutdown properly in the middle of this "sleeping" state, but it will still not respond to actions that you want to be suspended during the "sleeping" state.
Pete
.
- Follow-Ups:
- Re: Windows service shutdown
- From: tshad
- Re: Windows service shutdown
- References:
- Windows service shutdown
- From: tshad
- Windows service shutdown
- Prev by Date: Hi group
- Next by Date: Re: Accessing object properties
- Previous by thread: Re: Windows service shutdown
- Next by thread: Re: Windows service shutdown
- Index(es):
Relevant Pages
|