简体   繁体   English

ASP.net在应用程序启动时创建无限循环

[英]ASP.net create infinite loop on application start to do work

I need to do some work on periodic basis, like check some data in DB and make some calculations if needed and store them back to DB. 我需要定期进行一些工作,例如检查数据库中的一些数据,并根据需要进行一些计算,然后将它们存储回数据库中。

The question is how bad is it to start infinite look with some "sleep and do work" in separate thread on application start which would perform all required task periodically until pool shutdown? 问题是,在应用程序启动时在单独的线程中以一些“睡眠并完成工作”来启动无限外观是多么糟糕,该线程将定期执行所有必需的任务,直到池关闭为止?

What are the downsides? 不利之处是什么? it feels for me like it may affect asp.net processing performance due to reusable/releasable concept of MVC resources, but I can't find any proof. 对我来说,由于MVC资源的可重用/可释放概念,它可能会影响asp.net的处理性能,但我找不到任何证据。

Would appreciate any links or hints, Thanks! 将不胜感激任何链接或提示,谢谢!

PS I realize that best place to do something like this is windows service but it introduce some difficulties with deployment on client environment and I am checking out for any other options if any. PS我意识到,做这样的事情的最佳去处是Windows服务,但它给客户端环境上的部署带来了一些困难,我正在检查是否有其他选择。

I would suggest you construct a simple Console App to do what you would like and then set a Scheduled Task to run the console app. 我建议您构造一个简单的控制台应用程序以执行所需的操作,然后设置一个计划任务以运行该控制台应用程序。

This is the method I have used to do maintenance utilities such as the one you are describing. 这是我用来执行维护实用程序(例如您所描述的实用程序)的方法。

Otherwise, in an Asp.net app, the worker process could be reset, the host might have an Idle Timeout triggered. 否则,在Asp.net应用程序中,可以重置工作进程,主机可能触发了空闲超时。 And generally I think it would be the wrong approach when a very simple console app will use the language you prefer and accomplish the same task. 通常,当一个非常简单的控制台应用程序使用您喜欢的语言并完成相同的任务时,我认为这将是错误的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM