繁体   English   中英

“ await”运算符只能在异步lambda表达式中使用Windows Phone 8

[英]The 'await' operator can only be used within an async lambda expression Windows Phone 8

我在调用CustomMessageBox左键单击时调用了异步方法。 但是它给我带来了时间错误。 我用谷歌搜索它,但是得到了一些有关MessageDialog.Command的信息。 我将如何在Windows Phone CustomMessageBox实现相同CustomMessageBox

这是我的代码

CustomMessageBox customMBox = new CustomMessageBox()
                {
                    Caption = "Alert!",
                    Message = string.Format("Clicking on clear all will clear all the data on the app. Are you sure you want to proceed?"),
                    LeftButtonContent = "Yes",
                    RightButtonContent = "No",
                };

                customMBox.Dismissed += (s2, e2) =>
                {
                    switch (e2.Result)
                    {
                        case CustomMessageBoxResult.LeftButton:
                            await clearDatabaseAsync();
                            break;
                        case CustomMessageBoxResult.RightButton:
                            break;
                        case CustomMessageBoxResult.None:
                            break;
                        default:
                            break;
                    }
                };

                customMBox.Show();

    public async Task clearDatabaseAsync()
    {
       //SQLite clear table record logic
        await App.DeleteDatabase();           

    }

有人可以建议我如何实现这一目标吗?

提前致谢。

像错误提示一样尝试-使用async lambda expression

customMBox.Dismissed += async (s2, e2) => // rest of the code ...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM