项目代码如下

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); 

问题解决

相关文章:

  • 2021-05-24
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2022-12-23
  • 2021-07-03
  • 2021-11-25
猜你喜欢
  • 2021-07-24
  • 2021-07-28
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2021-12-07
相关资源
相似解决方案