public async override Task <DialogTurnResult> BeginDialogAsync(DialogContext outerDc, object options = null, CancellationToken cancellationToken = default(CancellationToken)) { await StartAsync(outerDc); if (NextMethod != null) { outerDc.ActiveDialog.State["WaitMethod"] = NextMethod.Method.Name; //consume the next method that was just setup in StartAsync MessageReceivedAsync callNext = NextMethod; NextMethod = null; await callNext(outerDc, outerDc.Context.Activity.AsMessageActivity()); } return(new DialogTurnResult(DialogTurnStatus.Waiting)); }
public static void Wait(this DialogContext dc, MessageReceivedAsync method) { var dialog = dc.Dialogs.Find(dc.ActiveDialog.Id); if (dialog != null) { var asV3 = dialog as BridgeComponentDialog; if (asV3 != null) { if (asV3.NextMethod != null) { throw new InvalidOperationException("Dialog .NextMethod was not executed before the attempt to set it. (.Wait with missing execution)"); } asV3.NextMethod = method; dc.ActiveDialog.State["WaitMethod"] = method.Method.Name; } } }