Skip to content

Commit

Permalink
Merge pull request #1212 from Microsoft/johtaylo/transcript-logger-co…
Browse files Browse the repository at this point in the history
…ntinuation

replace await with ContinueWith in Transcript middleware
  • Loading branch information
johnataylor committed Dec 4, 2018
2 parents 3adb332 + 6689668 commit 5b707fe
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions libraries/Microsoft.Bot.Builder/TranscriptLoggerMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Schema;
Expand Down Expand Up @@ -104,15 +105,24 @@ public async Task OnTurnAsync(ITurnContext turnContext, NextDelegate nextTurn, C
// flush transcript at end of turn
while (transcript.Count > 0)
{
try
{
var activity = transcript.Dequeue();
await logger.LogActivityAsync(activity).ConfigureAwait(false);
}
catch (Exception err)
{
System.Diagnostics.Trace.TraceError($"Transcript logActivity failed with {err}");
}
var activity = transcript.Dequeue();

// As we are deliberately not using await, disable teh associated warning.
#pragma warning disable 4014
logger.LogActivityAsync(activity).ContinueWith(
task =>
{
try
{
task.Wait();
}
catch (Exception err)
{
Trace.TraceError($"Transcript logActivity failed with {err}");
}
},
cancellationToken);
#pragma warning restore 4014
}
}

Expand Down

0 comments on commit 5b707fe

Please sign in to comment.