我有以下代码:
private async void ContextMenuForGroupRightTapped(object sender, RightTappedRoutedEventArgs args)
{
CheckBox ckbx = null;
if (sender is CheckBox)
{
ckbx = sender as CheckBox;
}
if (null == ckbx)
{
return;
}
string groupName = ckbx.Content.ToString();
var contextMenu = new PopupMenu();
// Add a command to edit the current Group
contextMenu.Commands.Add(new UICommand("Edit this Group", (contextMenuCmd) =>
{
Frame.Navigate(typeof(LocationGroupCreator), groupName);
}));
// Add a command to delete the current Group
contextMenu.Commands.Add(new UICommand("Delete this Group", (contextMenuCmd) =>
{
SQLiteUtils slu = new SQLiteUtils();
slu.DeleteGroupAsync(groupName); // this line raises Resharper's hackles, but appending await raises err msg. Where should the "async" be?
}));
// Show the context menu at the position the image was right-clicked
await contextMenu.ShowAsync(args.GetPosition(this));
}
... Resharper的检查抱怨:“ 由于未等待此调用,因此在调用完成之前将继续执行当前方法。请考虑将'await'运算符应用于调用结果 ”(与评论)。
因此,我给它添加了一个“等待”,但是,当然,我也需要在某个地方添加一个“异步”-但是在哪里?
1
docs.microsoft.com/en-us/dotnet/csharp/programming-guide/...
—
萨米人
@samsara:很好,我想知道他们何时最终在C#规范之外的地方对此进行了记录。IIRC,在提出此问题时尚无文档。
—
BoltClock