Windows Service自托管应用程序启动时,必须预加载数据,这可能需要60秒。所以应用程序调用
RequestAdditionalTime
启动时,以避免超时错误。
这之前很好用。
最近我们升级到ASP。NET Core 2.0,在Windows服务中自托管,该方法在Microsoft文档中描述
here
.
TargetFramework
即将
net472
在派生类中
WebHostService
,
请求额外时间
如下所示。
public class CustomWebHostService : WebHostService
{
public CustomWebHostService(IWebHost host) : base(host)
{
}
protected override void OnStarting(string[] args)
{
this.RequestAdditionalTime(1000 * 60 * 5);
base.OnStarting(args);
}
protected override void OnStarted()
{
this.RequestAdditionalTime(1000 * 60 * 5);
base.OnStarted();
}
}
但它不起作用。
服务未及时响应启动或控制请求。
在等待XXXX服务连接时,达到超时(30000毫秒)。
现在,我通过编辑注册表修复了此问题
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control]
"ServicesPipeTimeout"=dword:0002bf20
有人知道为什么吗
请求额外时间
不再工作了?