I have ASP.NET project and i need my project to run pice of code
我有ASP.NET项目,我需要我的项目来运行代码
void f()
{
while (true)
{
//Do important thing
}
}
Where i can put my code to ensure that this code is running in any time?
我可以在哪里放置代码以确保此代码在任何时间运行?
1 个解决方案
#1
1
There isn't as I know a reliable solution to run a background task on Asp.net. Due to the nature of the architecture a recycle can happen at any time killing your process. Usually the best solution is to have an out of process app (win service, scheduled task, ..) that do your job.
我不知道在Asp.net上运行后台任务的可靠解决方案。由于架构的性质,循环可以在任何时候发生,从而杀死您的过程。通常最好的解决方案是拥有一个完成工作的进程外应用程序(赢得服务,计划任务......)。
If you really need it inside asp.net maybe you can use this solution: http://blog.*.com/2008/07/easy-background-tasks-in-aspnet/
如果你真的需要它在asp.net内,也许你可以使用这个解决方案:http://blog.*.com/2008/07/easy-background-tasks-in-aspnet/
Basically you can use an item cache with an expiration callback to simulate a scheduled task.
基本上,您可以使用带有过期回调的项缓存来模拟计划任务。
As a final note consider that some hosting providers have proprietary solution that you can use to run background process.
最后需要注意的是,某些托管服务提供商拥有可用于运行后台进程的专有解决方案。
#1
1
There isn't as I know a reliable solution to run a background task on Asp.net. Due to the nature of the architecture a recycle can happen at any time killing your process. Usually the best solution is to have an out of process app (win service, scheduled task, ..) that do your job.
我不知道在Asp.net上运行后台任务的可靠解决方案。由于架构的性质,循环可以在任何时候发生,从而杀死您的过程。通常最好的解决方案是拥有一个完成工作的进程外应用程序(赢得服务,计划任务......)。
If you really need it inside asp.net maybe you can use this solution: http://blog.*.com/2008/07/easy-background-tasks-in-aspnet/
如果你真的需要它在asp.net内,也许你可以使用这个解决方案:http://blog.*.com/2008/07/easy-background-tasks-in-aspnet/
Basically you can use an item cache with an expiration callback to simulate a scheduled task.
基本上,您可以使用带有过期回调的项缓存来模拟计划任务。
As a final note consider that some hosting providers have proprietary solution that you can use to run background process.
最后需要注意的是,某些托管服务提供商拥有可用于运行后台进程的专有解决方案。