Does anybody know how to stop the Console.ReadLine method, when it's running on a different thread?
Right now I use a code (the loop part of it) that works like this:
while (true)
{
while (!Console.KeyAvailable) Thread.Sleep(100);
string line = Console.ReadLine();
}
It does work, but the problem is that as soon as I type a single character, the server won't shutdown.
Does anybody know how to achieve this? (Completely different approaches welcome too, as long as it allows me to read console lines, after I call a Start() method, and that it stops after a Stop() method call.)