protected override async void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
var content = (Content) Application.Current.Resources["NavigationParam"];
titleName.Text = content.title;
var uri = new Uri(content.url, UriKind.Absolute);
imageShow.Source = new BitmapImage(uri);
}
Severity Code Description Project File Line Column Warning CS1998 This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. ImageParser C:\Users\Johny\Documents\Visual Studio 2015\Projects\ImageParser\ImdbSample\ItemView.xaml.cs 26 41
最佳答案
您没有在方法主体内等待任何异步操作(通过使用 await
运算符),因此您的方法定义中的 async
关键字不是必需的。只需删除它,警告就会消失。
这不会改变您的方法的语义。正如警告消息明确指出的那样,它已经同步运行了。
关于c# - 在这个函数中放在哪里等待?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34038080/