循环通过PromptDialog.Choice对话框(Bot框架)

时间:2017-11-08 15:43:00

标签: c# botframework

我尝试在尝试达到给定计数时创建PromptDialog.Choice,它会给出预定义的错误,如:

  

太多的尝试

我已经在try catch中实现了回调函数,但调试没有达到catch部分,因此我可以再次循环。

调用函数

PromptDialog.Choice(context,
            PromptOperations, new string[] { "Add", "Subtract", "Multiply", "Division" },
            $"Hey " + name + "\n\n Select what do you want to perform today ?",
            "Didn't get that", 3,
            PromptStyle.Keyboard);

回叫功能

private async Task PromptOperations(IDialogContext context, IAwaitable<string> result)
        {
            try
            {
                //Some Operations
            }
            catch (Exception ex)
            {
                //Exceeded Attempts Loop Again
                PromptDialog.Choice(context,
                PromptOperations, new string[] { "Add", "Subtract", "Multiply", "Division" },
                "Please select valid option",
                "Didn't get that", 3,
                PromptStyle.Keyboard);
            }
        }

1 个答案:

答案 0 :(得分:0)

您错过了try部分的catch,迫使其转到try { var selection = await result; // some operations } 部分。

{{1}}