在asp.net程序长时间运行code [英] Long-running code within asp.net process
问题描述
例如。我们在code在asp.net形式codebihind:
私人无效btnSendEmails_OnClick()
{
Send100000EmailsAndWaitForReplies();
}
这code的执行将被暂停的原因被杀害。 为了解决这个问题,我想看到这样的内容:
私人无效btnSendEmails_OnClick()
{
变种的TaskID = AsyncTask.Run(()=> Send100000EmailsAndWaitForReplies());
//保存任务id为未来的任务执行状态检查。
}
和此方法将用于w3wp.exe进程之外的一些方法中有一个特殊enveronment执行。
是否有人知道一个框架/工具集来解决这样的问题?
更新:的电子邮件发送方法只不过是我的意思的例子。其实,我可以有很多的功能所需要的asp.net工作进程以外执行。
例如。这一点是从一对夫妇的第三方服务聚合数据的应用非常重要,用它做什么,它发回给其他服务。
- <一个href="http://blogs.msdn.com/b/webdev/archive/2014/06/04/queuebackgroundworkitem-to-reliably-schedule-and-run-long-background-process-in-asp-net.aspx"相对=nofollow> QueueBackgroundWorkItem 我的示例显示了发送电子邮件。
- 迟发型开源项目工程共同主办。
- 在Azure中,你可以使用<一个href="http://www.asp.net/aspnet/overview/developing-apps-with-windows-azure/azure-webjobs-recommended-resources"相对=nofollow> WebJobs 。
- 在Azure中,云服务一>
E.g. we this code in the asp.net form codebihind:
private void btnSendEmails_OnClick()
{
Send100000EmailsAndWaitForReplies();
}
This code execution will be killed by the timeout reason. For resolving the problem I'd like to see something like this:
private void btnSendEmails_OnClick()
{
var taskId = AsyncTask.Run( () => Send100000EmailsAndWaitForReplies() );
// Store taskId for future task execution status checking.
}
And this method will be executed for some way outside the w3wp.exe process within a special enveronment.
Does anybody know a framework/toolset for resolving this kind of issues?
Update: The emails sending method is only an example of what I mean. In fact, I could have a lot of functionality need to be executed outside the asp.net working process.
E.g. this point is very important for an application which aggregates data from a couple of 3rd party services, do something with it and send it back to another service.
- QueueBackgroundWorkItem My sample shows sending email.
- HangFire Open source project works on shared hosting.
- On Azure, you can use WebJobs.
- On Azure, Cloud services
这篇关于在asp.net程序长时间运行code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!