【发布时间】:2011-07-24 21:54:00
【问题描述】:
我有一个 ASP.NET MVC 3 (.NET 4) Web 应用程序。
我有一个[HttpPost] 操作方法,可以将一些数据提交到数据库。
现在,在此方法完成对存储库的持久化后,我希望执行“后台”任务(考虑审核或发送电子邮件等),我不关心结果(除非发生错误,在这种情况下,我将执行日志记录)。
我如何/应该如何从我的操作方法中触发此任务?
[HttpPost]
[Authorize]
public ActionResult Create(MyViewModel model)
{
if (ModelState.IsValid)
{
_repo.Save(model);
// TODO: Fire off thread
return RedirectToRoute("Somepage", new { id = model.id });
}
return View(model);
}
【问题讨论】:
-
您可能需要考虑像 nServiceBus 这样的服务总线或使用此处描述的 MSMQ - dotnetslackers.com/articles/aspnet/…
标签: c# multithreading asp.net-mvc-3 .net-4.0 threadpool