Using “async” (even if it should complete) as part of a MVC route deadlocks the route; how can this be avoided?

前端 未结 3 440
悲哀的现实
悲哀的现实 2020-12-24 08:45

Consider the following (based on the default MVC template), which is a simplified version of some \"stuff\" that happens in the background - it completes fine, and shows the

3条回答
  •  一个人的身影
    2020-12-24 09:21

    Another fix is to use async/await throughout:

    public async Task Index()
    {
        var task = IndirectSlowDouble(10);
        long result = await task;
        ViewBag.Message = result.ToString();
        return View();
    }
    

提交回复
热议问题