.NET Windows 系统关闭时服务停止顺序

.NET Windows Services stopping order when the system shutdown

我正在创建一个 windows 服务,该服务应该在系统关闭时向位于同一台机器上的 RESTFull 服务发送请求。 我想确保我的服务 OnStop() 事件将在 IIS 服务停止之前触发。 有什么方法可以控制服务关闭的顺序吗?

微软documents这个:

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

stack exchange 的姊妹站点上关于此的信息很少,因此我提供 link 而不是复制内容:https://serverfault.com/questions/34427/windows-service-dependencies