I have simple chat app (Console application), that behaves like that (simplified):
while(true){
var message = Console.ReadLine();
SendMessage(message);
}
Sometimes server asks some questions, like: "Do you want to remove user1 from chat?". It appears in users Console as soon as it come from from server.
Console.WriteLine("Do you want to remove user1 from chat? y/n");
var answer = Console.ReadLine();
if(answer == "y")
RemoveUser();
But there is a problem: I'm calling ReadLine() method to get "message" first and usually later comes server message with ReadLine() that waits for "answer". So when user wants to answer "server question", he have to write something to "message" first (because this ReadLine was called first!)
So is there a way to tell computer that particular ReadLine() call is more important than others and it have to get data first? Can I change the order of getting data from user?