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 Waga wrote: > 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" wrote in message news:erOu$mcRFHA.3104@TK2MSFTNGP10.phx.gbl... > Jan Waga wrote: >> 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 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.
Willy Denoyette [MVP] wrote: > 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. That's great! Maybe if you get a moment you can share what else is new? Do they expose the underlying API handle as well? - Lee