C#控制台程序读取输入按键非阻塞方式

参考内容:
http://www.dutton.me.uk/2009-02-24/non-blocking-keyboard-input-in-c/

相关代码:

while (true)
{
    if (Console.KeyAvailable)
    {
        ConsoleKeyInfo key = Console.ReadKey(true);
        switch (key.Key)
        {
            case ConsoleKey.F1:
                Console.WriteLine("You pressed F1!");
                break;
            default:
                break;
        }
    }
    // Do something more useful
}

你可能感兴趣的:(c#,开发语言)