【发布时间】:2015-11-29 01:24:01
【问题描述】:
我正在尝试使用 Topshelf 框架来创建 Windows 服务。但是当我尝试启动服务时,出现了这个异常:
" 服务启动失败... System.Service.Process.TimeoutException : 等待期已过,操作未完成"
这是我的代码:
public class MyService : ServiceControl
{
private System.Timers.Timer _timer;
public void MyService()
{
_timer = new System.Timers.Timer(10);
_timer.AutoReset = false;
_timer.Elapsed += new ElapsedEventHandler(TimerOnElapsed);
}
private void TimerOnElapsed(object source, ElapsedEventArgs e)
{
//all the operation to do at the startup
}
public bool Start(HostControl hostControl)
{
_timer.Start();
return true;
}
public bool Stop(HostControl hostControl)
{
_timer.Stop();
return true;
}
}
感谢您的帮助:)
【问题讨论】:
标签: exception timeout topshelf