【发布时间】:2013-11-08 15:48:28
【问题描述】:
我正在用 c# 编写一个 button_click 函数,在其中我使用 executeCommand 与服务对话。
ServiceController sc = new ServiceController("MyService");
int command = 145;
sc.Stop();
//writing xml file
sc.Start();
sc.ExecuteCommand(command);
有时程序崩溃,无法调用执行命令,因为服务处于启动/停止挂起状态。我该怎么办? 我需要停止/启动服务,因为该函数必须编写相同的 xml 文件。
【问题讨论】:
标签: c# servicecontroller