I'm building a .NET 4.0 console application which is constantly (that is, every few seconds usually) writing out to the console. It's a multi-threaded app and different threads write to the console at different times.
The problem is that I want to accept user input while all this is happening. The user input could occur at any time.
I tried tried two different methods, and neither worked very well.
I tried using a separate thread for reading by looking for
Console.KeyAvailable. This "worked" but was really confusing because strings were being written to output as you were trying to input. This made the cursor move around while typing and was disorienting.I tried using
Console.SetCursorPositionto split the console into two "panes". Output up top and input down below. This also worked but I have to callConsole.Clear()after drawing the screen each time. This was very slow and caused mad screen flickering.
It seems like my only other option is to write a Windows Forms app or WPF app to emulate the console. This seems ridiculous since the only thing I want to do is to accept spontaneous user input.
My google-fu did not turn up any valid console replacements or anyone who had build a .NET app that simulated the console....
Am I stuck here?