Block Console Application until text is written to Standard Out

I have a console application that is a TestHarness for testing a NuGet package. That NuGet package has a fire and forget async method. For normal usage, fire and forget is perfect (it is logging).

But in the event that something goes wrong, there is a option to write it out to standard out (well, really standard error).

When testing this I can just do a Task.Delay(2000); after my call. The text is usually written during that time. But sometimes it does not get out in time. Then the console looks like it is reporting an error on another part of the console application (because it does eventually get written).

Is there a way to block execution of my console application until text gets written to standard out (or standard error)?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.