Skip to content

Question about Process redirected output and WaitForExit  #65377

@Evangelink

Description

@Evangelink

Hi!

I am investigating an issue on vstest and I have nailed down the issue to the fact we receive the exit callback before we have flushed all the output/error messages.

Looking here, I have found the issue When Process.WaitForExitCore(int milliseconds) waits successfully, the redirected output streams miss some data which seems to solve our problem.

But, I am not sure which of the discussed solution is the one to rely apply (i.e. WaitForExitAsync, multi calls to WaitForExit, or read until null). The various solutions seem to work but I guess there is one solution to favor and it's not clear what/why.
I think that I simply need to replace the call to p.WaitForExit(500) by an awaited call to WaitForExitAsync with a cancellation token that times out.

Thank you for your feedback/answer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Diagnostics.ProcessquestionAnswer questions and provide assistance, not an issue with source code or documentation.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions