When building a Windows Console App in C#, is it possible to update lines in the console while waiting for a readline?
My current code is:
do
{
Console.Clear();
Console.WriteLine("RA: " + scope.RightAscension);
Console.WriteLine("Dec: " + scope.Declination);
Console.WriteLine("Status: " + scope.Slewing);
System.Threading.Thread.Sleep(1000);
} while (true);
Yes. You can write to the Console from a separate thread while blocking on Console.ReadLine.
That being said, it’s going to cause confusion. In your case, you’ll clear out what the user is typing half-way through their line (via Console.Clear()), plus move the cursor position around dramatically.
Edit: Here’s an example that shows this:
If you run this, you’ll see the Console waits on ReadLine, but the background thread still prints.