-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Server: Flush console output periodically #10231
Conversation
@YuliiaKovalova I was trying to make a nice video of the before/after where this was working/not, but my most recent 8.0.3xx MSBuild didn't reproduce it--I think this regressed from #9983, somehow. |
could you please check if reverting this change addresses it? |
Yup, reverting just that file (and suppressing the warning) fixes the problem. Though I don't see how! |
Ah, I see what happened. Before your change, The current version of this PR fixes it but breaks the thread safety. I think I'll manage the locking manually without |
2258033
to
d45db30
Compare
It looks like you address this ticket here: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK.
I'd just probably prefer if the resulting string handling callback is not part of the synchronization here. It doesn't already concern the writer, but rather the external processing of the data (sending them down the pipe)
d45db30
to
baef067
Compare
Initially, this delegated thread safety to a `SyncTextWriter`, but the object graph was hard to understand, so it was replaced with a has-a `SyncTextWriter` relationship, but this lost the timer-based call to `Flush()` to send the output to the client. The docs on `MethodImplOptions.Synchronized` also advise that it can be risky due to locking on the object itself, so manage the syncronization with an explicit lock object over the underlying `StringWriter` instead.
baef067
to
7310f74
Compare
This was the intention of the prior call, but
_syncWriter.Flush()
isa noop because it's a wrapper around a
TextWriter
; instead we need toflush the
RedirectConsoleWriter
itself, an operation which sends theaccumulated text to the client.