如何在MVC 3中异步执行方法?

时间:2012-08-10 19:36:43

标签: asp.net-mvc-3 asynchronous parallel-processing

是否可以在MVC3 Action方法中异步/并行调用方法?

public ActionResult CreateUser(string name,string password)
{
 int newUserId=  myRepositary.CreateUser(name,password)
 if(newUserID>0)
 {
   //i want to execute this asycn /parallel ?
   UpdateUserIDINRelatedTables();
 }
 return RedirectToAction("AccountCreated");
}
public void UpdateUserIDINRelatedTables()
{
  //I will  update the userId in few another tables.

}

UpdateUserIDINRelatedTables做了一些后端工作,将新的USERID与soemeother表相关联。我想在执行CreateUser方法后立即重定向到AccountCreated视图(不想等到UpdateUserIDInRelatedTables()方法完成执行。有什么想法吗?(在C#4,MVC3中)

1 个答案:

答案 0 :(得分:0)

尝试异步控制器。 这可能对你有所帮助 http://msdn.microsoft.com/en-us/library/ee728598(v=vs.100).aspx

相关问题