Example #1
0
        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();
            }
        }