diff --git a/libraries/Microsoft.Bot.Builder/ShowTypingMiddleware.cs b/libraries/Microsoft.Bot.Builder/ShowTypingMiddleware.cs
index 86c15892dd..e51cd0c68c 100644
--- a/libraries/Microsoft.Bot.Builder/ShowTypingMiddleware.cs
+++ b/libraries/Microsoft.Bot.Builder/ShowTypingMiddleware.cs
@@ -66,19 +66,13 @@ public async Task OnTurnAsync(ITurnContext turnContext, NextDelegate next, Cance
var containsMessage = activities.Any(e => e.Type == ActivityTypes.Message);
if (containsMessage)
{
- await FinishTypingTaskAsync(ctx).ConfigureAwait(false);
+ await ProcessTypingAsync(ctx).ConfigureAwait(false);
}
return await nextSend().ConfigureAwait(false);
});
- // Start a timer to periodically send the typing activity (bots running as skills should not send typing activity)
- if (!IsSkillBot(turnContext) && turnContext.Activity.Type == ActivityTypes.Message)
- {
- // Override the typing background task.
- await FinishTypingTaskAsync(turnContext).ConfigureAwait(false);
- StartTypingTask(turnContext);
- }
+ await ProcessTypingAsync(turnContext).ConfigureAwait(false);
await next(cancellationToken).ConfigureAwait(false);
@@ -177,5 +171,19 @@ private async Task FinishTypingTaskAsync(ITurnContext turnContext)
_tasks.TryRemove(turnContext.Activity.Conversation.Id, out _);
}
+
+ ///
+ /// Start a timer to periodically send the typing activity (bots running as skills should not send typing activity).
+ ///
+ /// The context object for this turn.
+ private async Task ProcessTypingAsync(ITurnContext turnContext)
+ {
+ if (!IsSkillBot(turnContext) && turnContext.Activity.Type == ActivityTypes.Message)
+ {
+ // Override the typing background task.
+ await FinishTypingTaskAsync(turnContext).ConfigureAwait(false);
+ StartTypingTask(turnContext);
+ }
+ }
}
}