23 Aralık 2012, Pazar
Nerede lambda ifade bir zaman uyumsuz mark?
Bu kod var:
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 denetim ile ilgili şikayet, " dediBu çağrıyı bekliyordu olmadığı için, geçerli yöntem yürütme çağrı tamamlanmadan devam ediyor. 'Bekliyor' arama sonucuna operatör . uygulama ele "(açıklama satırı).
Ve bu yüzden, "" ama, tabii ki, ben o zaman bir ekleme gerekiyor "uyumsuz" bir yerlerde, Ama nerede? çok bekliyor bir ben e
CEVAP
23 Aralık 2012, Pazar
Lambda uyumsuz işaretlemek için, yalnızca bağımsız değişken listesi: async
önüne
// Add a command to delete the current Group
contextMenu.Commands.Add(new UICommand("Delete this Group", async (contextMenuCmd) =>
{
SQLiteUtils slu = new SQLiteUtils();
await slu.DeleteGroupAsync(groupName);
}));
Bunu Paylaş:
Ne zaman uyumsuz ve paralel programlam...
Lambda ifade öbek üzerinde bir nesne h...
nasıl ve zaman uyumsuz kullanmak `ve` ...
C 11 vadeli işlemler kullanarak: std ç...
Nasıl test zaman uyumsuz API birim içi...