我已經下載EF6(爲了使用async
)EntityFramework(6)和異步(waitingForActivation)?
所以我寫了這個簡單的方法:
public async Task<List<int>> MyasyncMethod()
{
var locations = await MyDumpEntities.AgeGroups.Select(f=>f.endYear).ToListAsync();
return locations;
}
...Later...
DumpEntities1 MyDumpEntities = new DumpEntities1();
var data = MyDumpEntities.AgeGroups.ToListAsync();
MyasyncMethod().ContinueWith(s => { Response.Write("f"); });
MyDumpEntities.Dispose();
,但我沒有看到任何屏幕上,當我檢查data
我看到這個:
PS這是ToListAsync
簽名
我在想什麼?
你不'await'ing這個電話,你應該去'VAR數據=等待MyDumpEntities.AgeGroups.ToListAsync();'... –
他不是等待呼叫對MyasyncMethod()的調用返回任務? – CodingIntrigue
@PatrykĆwieknoope http://i.stack.imgur.com/WqdZb.png –