contoso flowers sample顯示如果收到特定單詞(例如「設置」)並「注入」設置對話框,如何中斷流程。可通過對話框中斷並獲得結果進行分類
在我迄今見過的所有例子是往這個方向,都使用VoidDialog這樣的:
public async Task PostAsync(IActivity item, object state, CancellationToken token)
{
var message = item as IMessageActivity;
if (message != null)
{
var settingsDialog = new SettingsDialog(this.dialogFactory);
// wrap it with an additional dialog that will restart the wait for
// messages from the user once the child dialog has finished
var interruption = settingsDialog.Void<object, IMessageActivity>();
// put the interrupting dialog on the stack
this.task.Call(interruption, null);
// start running the interrupting dialog
await this.task.PollAsync(token);
}
}
以我爲例,我需要得到的結果形成包裹對話框(比如說從設置對話框),但我無法弄清楚如何做到這一點。
我需要做類似DeleteProfileScorable的事情,但我想詢問用戶他是否真的想繼續,所以我創建了一個對話框來詢問這個問題。我需要從該對話框以外得到結果(好或不好),因爲stack.Reset()
似乎不能在對話框中工作(「堆棧爲空」錯誤)。
我也試圖在這裏this.task.Call(interruption, MyResumeHandler);
添加恢復處理程序,但是這給了我這個錯誤:
IDialog method execution finished with multiple resume handlers specified through IDialogStack.
調用對話也直接導致此錯誤。
我也複製了來自VoidDialog的源代碼並將其改爲我的需要,但我總是與相同類型的錯誤糾纏在一起。
我想解決方案可能非常簡單,但經過幾個小時的嘗試和錯誤,我希望有人能幫助我?
問題是,我需要得到結果(布爾,如果中止是好還是不好),因爲只有那裏我可以調用stack.Reset()沒有例外。 – martinoss