I'm creating a windows service that is supposed to send a request to a RESTFull service that is located on the same machine when the system shutdown. I want to make sure that my service OnStop() event will fire before the IIS service is stopped. Is there a way that I can control the order of services closure?
Asked
Active
Viewed 845 times
1 Answers
3
Microsoft documents this:
To set the shutdown order of services manually, create a multistring registry value that contains the service names in the order in which they should be shut down and assign it to the Control key's PreshutdownOrder value, as follows
There is little information about this on a sister site of stack exchange, so I provide the link instead of copying the content: https://serverfault.com/questions/34427/windows-service-dependencies
-
thanks a lot your answer helped me so much. is there a way to manage the order of services starting too? – Heba Gomaah Oct 19 '15 at 10:29
-
1yes, have a look at the last answer in this post: http://stackoverflow.com/questions/6155913/run-windows-services-in-specific-order . And: using the search might help ;-) – Marged Oct 19 '15 at 10:35
-
i found that way already but was wondering whether there is a way to control it from registry just like the shutdown. Thanks again :) – Heba Gomaah Oct 19 '15 at 10:41
-
1The linked answer contains a link to Microsoft which tells you how to use registry to do this. – Marged Oct 19 '15 at 10:48