为什么被调用的对话框在从另一个对话框调用时不等待 MessageReceivedAsync

Why does a called dialog not wait for MessageReceivedAsync when it is called from another

大家好我正在使用 Microsoft Bot Framework 构建一个机器人,我制作了一个调度对话框,当它从 LUIS 接收结果时调用另一个对话框,但是当我使用 context.Forward() 方法调用下一个对话框时, 它通过 public async Task StartAsync(IDialogContext context) 但是虽然我使用 context.Wait(MessageReceivedAsync); 方法,我的对话框从不等待用户的消息通过返回到调用它的对话框继续执行。

我看了答案 但它并没有解决我的问题。

这就是我调用对话框的方式:

await context.Forward(scheduleDialog,ScheduleDialogTerminated,context.MakeMessage(), CancellationToken.None);

这是名为的对话框:

public class ScheduleDialog : IDialog
    {
        IScheduler scheduler;
        string timeEntity;
        string appointmentEntity;
        string dateEntity;

        public ScheduleDialog(IScheduler scheduler, string date, string time, string appointment) : base()
        {
            dateEntity = date;
            timeEntity = time;
            appointmentEntity = appointment;

            this.scheduler = scheduler;
        }

        public async Task StartAsync(IDialogContext context)
        {
            string message = context.Activity.AsMessageActivity().Text;
            await context.PostAsync($"Scheduling... {message}");
            context.Wait(MessageReceivedAsync);
        }

        public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> argument)
        {
            await context.PostAsync("Waiting for message...");
        }
    }

MessageReceivedAsync 方法永远不会被调用,因为我指定上下文应该在 StartAsync 方法中等待它

您需要在 MessageReceivedAsync 方法的末尾添加一个 context.Wait(MessageReceivedAsync);