我这里有一段代码,想知道在哪里加上 await 关键字。我尝试过使用 lambda => 和普通方法,但都没有成功。
private async void ContextMenuAbroad(object sender, RightTappedRoutedEventArgs args)
{
CheckBox ckbx = null;
if (sender is CheckBox)
{
ckbx = sender as CheckBox;
}
if (null == ckbx)
{
return;
}
string nameOfGroup = ckbx.Content.ToString();
var contextMenu = new PopupMenu();
contextMenu.Commands.Add(new UICommand("Edit this Group", (contextMenuCmd) =>
{
Frame.Navigate(typeof(LocationGroupCreator), nameOfGroup );
}));
contextMenu.Commands.Add(new UICommand("Delete this Group", (contextMenuCmd) =>
{
SQLiteUtils rfd = new SQLiteUtils();
rfd.DeleteGroupAsync(nameOfGroup );
}));
await contextMenu.ShowAsync(args.GetPosition(this));
}
我添加了一个await,但我需要在某个地方添加async ... 但是应该在哪里添加呢?
Resharper的检查提示:"因为此调用未被等待,所以在完成调用之前,当前方法的执行将继续进行。考虑将'await'运算符应用于调用的结果"
非常感谢您的帮助!