首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >我在哪里标记一个异步的lambda表达式?

我在哪里标记一个异步的lambda表达式?
EN

Stack Overflow用户
提问于 2012-12-24 06:48:31
回答 3查看 178.3K关注 0票数 261

我有这样的代码:

代码语言:javascript
复制
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));
}

...that Resharper的检查抱怨道,“由于此调用不是等待的,因此在调用完成之前会继续执行当前方法。请考虑将'await‘运算符应用于调用的结果”(在带有注释的行上)。

因此,我在它前面添加了一个"await“,但是,当然,我也需要在某个地方添加一个"async”--但是在哪里呢?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14015319

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档