I’ve got the following code:
bool loop = true;
LongbowWorkerThread Worker = new LongbowWorkerThread();
Thread w = new Thread(Worker.UpdateChannel);
w.Start();
string inText = string.Empty;
while (loop) {
inText = Console.ReadLine();
Console.WriteLine(inText);
}
At this point, the worker thread simply echoes a string every 5000ms. The problem is that the printed string overlaps the user’s already-entered text, which isn’t ideal and looks quite ugly (although it doesn’t affect the actual data returned by Console.ReadLine.)
Is there a way to prevent this overlap?
You could use the Console.CursorLeft and Console.CursorRight properties to note the cursors location, shift it, output your text, then shift it back.
Edit: Here’s a sample I just threw together, works well based on the 60 seconds of testing I threw at it.