Visual Studio抱怨以下内容:
public RelayCommand SendRegistrationCommand { get; private set; } public async void SendRegistration() { HttpClient client = new HttpClient(); var response = await client.GetStringAsync("url"); // ... todo } Cannot await 'System.Threading.Tasks.Task<string>'
我以为我以前做过,GetStringAsync不等待?
解决方法
你可能是针对.NET 4.0.
如果可以,请切换到支持异步/等待语义的.NET 4.5.
如果不能,请考虑使用Async Targeting Pack:https://www.nuget.org/packages/Microsoft.CompilerServices.AsyncTargetingPack
编辑
根据评论,应该使用Microsoft.Bcl.Async:https://www.nuget.org/packages/Microsoft.Bcl.Async