![](/img/trans.png)
[英]Error accessing the Cache in the Application_Start method of Global.asax
[英]Web Service freezes after startup with Application_Start() method in Global.asax
我正在使用Web Service方法返回一个列表,该列表在Web Service启动后将执行约40秒(该方法是从Global.asax
Application_Start()
事件启动的)。
问题在于,Web Service在此方法需要的时间内被冻结,而我的应用程序直到获得此列表后才启动(实际上它已启动,但也被冻结,甚至不显示Form)。
有什么办法可以解决吗? 也许在Application_Start()
异步调用此方法? 任何帮助将不胜感激。
Global.asax中的代码:
protected void Application_Start(object sender, EventArgs e)
{
WebService WS = new WebService();
WS.RecursiveFileProcessor();
}
您可以将该机制作为单独的任务启动:
protected void Application_Start(object sender, EventArgs e)
{
Task.Factory.StartNew(() =>
{
WebService WS = new WebService();
WS.RecursiveFileProcessor();
});
}
这应该停止您的服务挂起。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.