Grz*_*nio 9 .net c# windows-services timeout
我已经部署了我的Windows服务(使用独立的安装程序类和SC.EXE),但是当我尝试启动它时出现错误:
---------------------------
Services
---------------------------
Could not start the MyName service on Local Computer.
Error 1053: The service did not respond to the start or control request in a timely fashion.
Run Code Online (Sandbox Code Playgroud)
什么是超时?感觉就像大约3秒钟.如果我的服务需要更长时间,我该怎么办?
Ben*_*n M 15
在您的服务类中,使用ServiceBase.RequestAdditionalTime()
OnStart/OnStop方法:
// request an additional 4 seconds to complete the operation
RequestAdditionalTime(4000);
Run Code Online (Sandbox Code Playgroud)
Ree*_*sey 13
创建服务的常规方法是让启动代码创建一个新线程,并在该线程中运行您的服务.
服务启动应该几乎是即时的 - 只不过是用你的"真实"工作产生一个新线程.
如果你花了三秒多的时间,这表明你在主线程中正在做真正的工作,而不是为你的服务创建一个单独的工作.
归档时间: |
|
查看次数: |
14386 次 |
最近记录: |