如何在Windows服务编程重新启动本身? [英] How can a windows service programmatically restart itself?
本文介绍了如何在Windows服务编程重新启动本身?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要写稳健code在.NET中,使窗口服务(服务器2003年)重新启动本身。什么是最好的方式,使这个?有一些.NET API办呢?
I need to write robust code in .NET to enable a windows service (server 2003) to restart itself. What is the best way to so this? Is there some .NET API to do it?
推荐答案
设置故障后重新启动(请双击控制面板中的服务,并在这些标签周围看看 - 我忘记了它的名字)的服务。然后,任何时候你想要的服务重新启动,只需拨打Environment.Exit(1)(或任何非归零)和操作系统将重新启动它。
Set the service to restart after failure (double click the service in the control panel and have a look around on those tabs - I forget the name of it). Then, anytime you want the service to restart, just call Environment.Exit(1) (or any non-zero return) and the OS will restart it for you.
这篇关于如何在Windows服务编程重新启动本身?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文