问题描述
我正在创建一个 Windows 服务,该服务应该在系统关闭时向位于同一台机器上的 RESTFull 服务发送请求.我想确保我的服务 OnStop() 事件将在 IIS 服务停止之前触发.有没有办法控制服务关闭的顺序?
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?
推荐答案
Microsoft 文档:
Microsoft documents this:
要手动设置服务的关闭顺序,请创建一个多字符串包含服务名称的注册表值他们应该被关闭并将其分配给 Control 键的PreshutdownOrder 值,如下
堆栈交换的姊妹站点上关于此的信息很少,因此我提供链接而不是复制内容:https://serverfault.com/questions/34427/windows-service-dependencies
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
这篇关于.NET Windows 服务在系统关闭时停止命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!