码迷,mamicode.com
首页 > 其他好文 > 详细

Controller中添加一个异步的Action

时间:2017-08-08 13:54:58      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:blog   syn   arc   port   hive   www.   sync   mvc   class   

给一段示例代码:

        public Task<ActionResult> TbReport(string code)
        {
            return Task.Factory.StartNew(() =>
            {
                ...
                return View(report);
                ...
                return View("");//未找到子报表
            }).ContinueWith<ActionResult>(task =>
            {
                return task.Result;
            }); 
        }

以上代码 StartNew() 括号中去异步执行,ContinueWith()执行完毕后返回值。


 

完整资料请访问:ASP.NET MVC下的异步Action的定义和执行原理

Controller中添加一个异步的Action

标签:blog   syn   arc   port   hive   www.   sync   mvc   class   

原文地址:http://www.cnblogs.com/senyier/p/7306224.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!