Skip to content

Commit

Permalink
ensure access to logger is synchronized for async output reader (#2133)
Browse files Browse the repository at this point in the history
fixes #2125
  • Loading branch information
adamsitnik committed Oct 5, 2022
1 parent f4d99ab commit 97c2d14
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/BenchmarkDotNet/Loggers/AsyncProcessOutputReader.cs
Expand Up @@ -106,8 +106,14 @@ private void ProcessOnOutputDataReceived(object sender, DataReceivedEventArgs e)
if (!string.IsNullOrEmpty(e.Data))
{
output.Enqueue(e.Data);

if (logOutput)
logger.WriteLine(e.Data);
{
lock (this) // #2125
{
logger.WriteLine(e.Data);
}
}
}
}

Expand All @@ -116,8 +122,14 @@ private void ProcessOnErrorDataReceived(object sender, DataReceivedEventArgs e)
if (!string.IsNullOrEmpty(e.Data))
{
error.Enqueue(e.Data);

if (logOutput)
logger.WriteLineError(e.Data);
{
lock (this) // #2125
{
logger.WriteLineError(e.Data);
}
}
}
}

Expand Down

0 comments on commit 97c2d14

Please sign in to comment.