【发布时间】:2011-06-09 12:15:57
【问题描述】:
我正在尝试使用以下代码停止本地计算机上的 Windows 服务(该服务是 Topshelf.Host,如果重要的话):
serviceController.Stop();
serviceController.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
timeout 设置为 1 小时,但服务实际上从未停止过。奇怪的是,在服务 MMC 管理单元中,我首先看到它处于“停止”状态,但过了一会儿它又恢复为“已启动”。但是,当我尝试手动停止它时,会出现错误:
Windows could not stop the Topshelf.Host service on Local Computer.
Error 1061: The service cannot accept control messages at this time.
我错过了什么吗?
【问题讨论】:
标签: windows-services servicecontroller