我想知道以下代码是否有任何我在网络服务器上运行时不知道的问题.阅读优秀的系列丛书http://reedcopsey.com/series/parallelism-in-net4/我无法找到与我的问题有关的任何内容,与msdn相同,所以我想我会把它带到这里.
示例电话:
public ActionResult Index() {
ViewBag.Message = "Welcome to ASP.NET MVC!";
Task.Factory.StartNew(() => {
//This is some long completing task that I don't care about
//Say logging to the database or updating certain information
System.Threading.Thread.Sleep(10000);
});
return View();
}
Run Code Online (Sandbox Code Playgroud)
ASP.Net支持异步页面,请参阅ASP.NET中的异步页面,但它是一个复杂的编程模型,并不与MVC完全绑定.话虽这么说,从同步请求处理程序启动异步任务可以解决问题:
归档时间: |
|
查看次数: |
2736 次 |
最近记录: |