如何在Windows服务编程重新启动本身?重新启动、如何在、Windows

2023-09-02 01:20:19 作者:戒不掉的放纵

我需要写稳健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.

 
精彩推荐
图片推荐