Ash,
If I am not mistaken, Windows ultimately will disregard requests for
more time after 30 seconds (I could be wrong on the time).
Frankly, it's not a good idea to keep the machine running for another
5-6 minutes if a user requested a shutdown. Is there any way that you can
write the data while the service is running, instead of dumping it all in
the end?
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
(E-Mail Removed)
"Ash" <(E-Mail Removed)> wrote in message
news:0A0653A2-0254-4A8C-A211-(E-Mail Removed)...
> Hi coders,
> I have a service that does alot of data copying to the database and when
> the
> service is stopped or the machine is shutting down it commits the data (in
> addition to other things) and makes sure it exists gracefully (this could
> take upto 5-6 mins).
>
> I tried increasing
> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WaitToKillServiceTimeout
> to 5 mins (300000) on a test service that sleeps for 4 mins when
> OnStop/Shutdown is called but that didnt work, I also tried using
> RequestAdditionalTime(290000) but again that didnt work.
> In all my test cases the SCM returns after 2 mins with Error 1053
> (timeout)
> and marks the service as stopping but never waits the time specified in
> RequestAdditionalTime or the WaitToKillServiceTimeout.
> ServiceBase.CanShutdown and ServiceBase.CanStop are both set to true
>
> In the case of the OnStop the SCM doesnt kill the EXE and service
> completes
> its task but if it is a Shutdown the exe gets killed before the time
> elapses.
>
> Am i missing somthing, are these settings being overwritten somewhere
> else?
> Note that
> Thanks alot.
> -Ash