SORU
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ş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Deany Boii

    Deany Boii

    27 Kasım 2007
  • REK Roth Productions

    REK Roth Pro

    8 Ocak 2011
  • Sam Kear

    Sam Kear

    14 Temmuz 2007