0
点赞
收藏
分享

微信扫一扫

System.ServiceProcess.TimeoutException: Time out has expired and the operation

萍儿的小确幸 2022-08-18 阅读 81

项目代码如下

ServiceController service = new ServiceController("ModbusAgent");
service.Stop();
TimeSpan timeout = new TimeSpan(50000);
service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);

按照Stackoverflow:​​Time out has expired and the operation has not been completed in Service manager​​的说法,不要对其设置服务超时

 于是代码改成:

ServiceController service = new ServiceController("ModbusAgent");
service.Stop();
service.WaitForStatus(ServiceControllerStatus.Stopped);

问题解决

举报

相关推荐

0 条评论