Windows服务可以阻止自己? [英] Can a Windows service stop itself?
本文介绍了Windows服务可以阻止自己?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Windows服务的启动类型为自动,但我想要做一些检查服务启动时,自动拥有该服务停止,如果这些检查失败。
I have a Windows service whose startup type is automatic, but I want to do some checks when the service starts, and have the service stop automatically if these checks fail.
我怎样才能做到这一点?我的服务是用C#编写。
How can I do this? My service is written in C#.
推荐答案
您可以致电停止
方法对你的 ServiceBase
类。请参见 MSDN 了解更多详情。
You can call the Stop
method on your ServiceBase
class. See msdn for more details.
这篇关于Windows服务可以阻止自己?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文