'.NET console application: how to get user input while constantly logging to console?

A .NET (Core) console application provides extensive console logging. At certain points the application needs user input, while still logging.

Problem: Unfortunately the flowing log pushes the input text and prompt up so the user cannot see it anymore. They can still enter something and press Return - which works - but it's utterly unintuitive.

How to solve this? I saw that PowerShell Core allows to show a progress bar "above" the log output using Write-Progress. Could this be something?

In a first step I need a solution for Windows. For other platforms I already use means like Zenity to get user input. (Providing an interactive prompt on Windows seems to be a bigger challenge than I hoped. But that's another topic.)

So how can I solve my problem: gathering user input in a console application while constantly logging output to the console window?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source