ho questo codice:Dove posso contrassegnare un'espressione lambda async?
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));
}
... che l'ispezione di ReSharper lamentato con "Perché questo invito non è atteso, l'esecuzione del metodo corrente continua prima che la chiamata è stata completata in considerazione l'applicazione del. 'attendere' l'operatore al risultato della chiamata "(sulla riga con il commento).
E così, ho anteposto una "attesa" ad esso, ma, naturalmente, ho poi bisogno di aggiungere un "async" da qualche parte, anche - ma dove?
così semplice ... ma non ovvio a tutti! +1 – ppumkin