.NET Windows 服务在系统关闭时停止命令 [英] .NET Windows Services stopping order when the system shutdown

查看:21
本文介绍了.NET Windows 服务在系统关闭时停止命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个 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 值,如下

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

堆栈交换的姊妹站点上关于此的信息很少,因此我提供链接而不是复制内容: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 服务在系统关闭时停止命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆