public async Task OnTurn(ITurnContext context) { await Padlock.WaitAsync(); // Start critical section try { await context.Continue(); IDialog dialog = null; if (!context.Replied) { if (context.CurrentDialog == null && _dialogs.Any(d => context.Activity.Command == d.Key)) { dialog = _dialogs[context.Activity.Command.ToLowerInvariant()]; } } if (dialog != null) { await context.Begin(dialog); } } finally { // End critical section Padlock.Release(); } }
public virtual async Task Begin(ITurnContext turnContext) { turnContext.EndCalled += TurnContextOnEndCalled; if (_childenDialogs.Any()) { _currentDialog = _childenDialogs.First(); await turnContext.Begin(_currentDialog); } }