System.ServiceProcess.TimeoutException: Time out has expired and the operation has not been complete
Posted 学习笔记
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了System.ServiceProcess.TimeoutException: Time out has expired and the operation has not been complete相关的知识,希望对你有一定的参考价值。
项目代码如下
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);
问题解决
以上是关于System.ServiceProcess.TimeoutException: Time out has expired and the operation has not been complete的主要内容,如果未能解决你的问题,请参考以下文章