async等待将数据传递给partialview mvc

时间:2013-06-14 22:52:18

标签: c# asp.net-mvc

在阅读本网站和其他人的帖子后,我发现你无法进行部分视图异步。所以我尝试了另一种方法,但是我得到了以下错误。

TaskTest Id = 1,Status = WaitingForActivation,Method =“{null}”,Result =“{Not yet computed}”System.Threading.Tasks.Task

如果可能,任何人都可以帮助解决这个问题。

private async Task<string> GetLocationName(string id)
        {
            var weatherSearchLocation = await Task.Run(()=> _igwccafdf.WeatherLocation(id).FirstOrDefault().WeatherLocation); //Works here, returns data
            return weatherSearchLocation;
        }

这是发生错误的地方

// Task<string> LocationTask = Task.Factory.StartNew<string>(GetLocationName);

            var TaskTest = GetLocationName("london");

我尝试过几种方法,但似乎都没有。

0 个答案:

没有答案