Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

making TextWriterTraceAdapter synchronized #1043

Merged
merged 1 commit into from
Mar 6, 2017
Merged

Conversation

brettsam
Copy link
Member

@brettsam brettsam commented Mar 6, 2017

Addresses #1042


public override void Write(char value)
{
// buffer all output
_text.Append(value);

int len = _text.Length;
if (len > 2 && _text[len - 2] == '\r' && _text[len - 1] == '\n')
if (len >= 2 && _text[len - 2] == '\r' && _text[len - 1] == '\n')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my test, I just log WriteLine(string.Empty) -- which looks like it just sends '\r\n'. In that case, the string length was only 2, so this logic didn't kick in like I would have expected. Instead, it waited until it had '\r\n\r\n' before flushing. It's a minor change -- but I thought it made sense.

TextWriter adapter = TextWriterTraceAdapter.Synchronized(trace);

// Start Tasks to write
List<Task> tasks = new List<Task>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this test repro the problem reliably?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, every time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants