[Mono-list] Console ReadKey not blocking returning 0, Mono 2.8.1, linux

chris6789 chris6789 at pacbell.net
Thu Dec 30 14:21:06 EST 2010


Anyone else experiencing problems using ReadKey on linux?  I'm using Mono
2.8.1, CentOs 5.4.  The following code just prints "Ignoring 0 0" over and
over (doesn't block).  ReadLine() also is not working.  Same code works on
Windows under Mono.

Thanks,
Chris


Console.WriteLine("Press ESCAPE to exit the main server thread...");                
ConsoleKeyInfo ki;                
while ((ki = Console.ReadKey(true)).Key != ConsoleKey.Escape) 
{                    
    if (ki.KeyChar == 0)    // readKey does not block on mono on linux
    {
        Thread.Sleep(500);
        Console.WriteLine("Ignoring " + (int)ki.KeyChar + ", " +
ki.Key.ToString());
        continue;
    }
    Console.WriteLine("Got a " + (int)ki.KeyChar);
}

Console.WriteLine("Main thread exiting...");

-- 
View this message in context: http://mono.1490590.n4.nabble.com/Console-ReadKey-not-blocking-returning-0-Mono-2-8-1-linux-tp3168655p3168655.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list