【发布时间】:2019-04-04 16:42:41
【问题描述】:
我有一个 Asp.Net 网络表单应用程序,在我的页面的 Page_Load event 中有以下代码
protected async void Page_Load(object sender, EventArgs e)
{
var data = await ChartDataHelper.GetBidsAverageCycle("2018", "Q4",
"Fiscal");
SomeSyncOperation();
}
这是主要方法
public static async Task<List<BidAveragceCycleModel>> GetBidsAverageCycle(string year, string quarter, string yearType)
{
SqlParameter parameter1 = new SqlParameter("@RequestData", BuildMonthsFilter(year, quarter, yearType));
var data =await Entities.Current.ExecuteStoreQueryAsync<BidAveragceCycleModel>("exec Dashboard_Bids_AverageCycleTime @RequestData"
, new[] { parameter1 });
return data.ToList();
}
我在想有await on the ExecuteStoreQueryAsync will return the control back to Page_Load and call SomeSyncOperation(),但看起来它正在synchronous fashion 中运行,10 秒后,当存储过程返回数据时,它会调用data.ToList(),然后只返回到Page_Load 调用。
有人可以告诉我我在这里做错了什么。
谢谢
【问题讨论】:
标签: c# asp.net .net async-await entity-framework-6