controlling windows service start and stop (shutdown) timeout

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
 
L

Lee Gillie

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
 
J

Jan Waga

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
 
W

Willy Denoyette [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top