Description
Hello, I have a console application that sends & receives data from a server. The problem I'm facing is if I want to print the result from the server using AnsiConsole.WriteLine
it will write the text on the same line as the prompt from AnsiConsole.AskAsync
, for example when the user sends "hello"
the server responds with "world"
:
Here is the AskAsync prompt: hello
Here is the AskAsync prompt: world <-- The response from the server is placed on the same line as the prompt
asd <-- The input itself continues on the next line
Here is the AskAsync prompt: hello
Here is the AskAsync prompt: world
hello
Here is the AskAsync prompt: world
asd
Here is the AskAsync prompt:
I would expect (want) it to look like this:
Here is the AskAsync prompt: hello
world <-- The response from the server is placed on its own line
Here is the AskAsync prompt: asd <-- The input continues on the next line
Here is the AskAsync prompt: hello
world
Here is the AskAsync prompt: hello
world
Here is the AskAsync prompt: asd
Here is the AskAsync prompt:
The code itself boils down to this:
HandleInputAsync();
while (true)
{
if (GetServerMessage(out var message))
{
AnsiConsole.WriteLine(message);
}
Thread.Sleep(100);
}
async void HandleInputAsync()
{
while (true)
{
var input = await AnsiConsole.AskAsync<string>("Here is the AskAsync prompt:");
Send(input); // Send input to server
}
}
I have tried many things like using cancellation tokens and to no avail, the prompt ("Here is the AskAsync prompt:") still stays before the message and the actual input is placed on a new line without the prompt before it. Is what I'm trying to do possible?
If important, I'm using the default cmd
console in Windows 10 (but behaviour is the same in all other consoles I've tested, like GitBash).
P.S. was not sure if I should mark this as a bug since it could be intended.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done 🚀