controlling windows service start and stop (shutdown) timeout

  • Thread starter Thread starter Jan Waga
  • Start date Start date
J

Jan Waga

Hello,

Is there some way to control SCM timeout while starting or stopping a C#
windows service? I know I can work on a different thread and quickly return
from OnStart(), but I'd like my service to shutdown gracefully, and it takes
a long time to save all data while exiting.

Thanks for any help,
Jan
 
Jan said:
Hello,

Is there some way to control SCM timeout while starting or stopping a C#
windows service? I know I can work on a different thread and quickly return
from OnStart(), but I'd like my service to shutdown gracefully, and it takes
a long time to save all data while exiting.

Thanks for any help,
Jan

There is a way in the Win SDK which .NET uses.
Part of the low level API provides a way for your service to HINT to the
SCM.

But .NET does not expose this (and a lot of other useful features!).

If .NET would ALSO expose its internal SCM handle, then you could call
WIN32 directly for the places it falls short.

I'm with you, I think all of this wonderful stuff should be there.

- Lee
 
Thank you, yesterday I found your post on DotNetMonster (or similar NET
portal, I don't recall). I guess I have to write ordinary C++ service and
call a process.

Jan
 
Lee Gillie said:
There is a way in the Win SDK which .NET uses.
Part of the low level API provides a way for your service to HINT to the
SCM.

But .NET does not expose this (and a lot of other useful features!).

If .NET would ALSO expose its internal SCM handle, then you could call
WIN32 directly for the places it falls short.

I'm with you, I think all of this wonderful stuff should be there.

- Lee

This is taken care of in v2.0 - see ServiceBase.RequestAdditionalTime(msecs)
method.
This method will hint the SCM to wait for additional msecs. time before it
decides a start/stop ... pending request failed.

Willy.
 
Back
Top