in src/Utilities.cs [293:318]
internal static ConsoleKeyInfo? ReadKeyWithTimeout(TimeSpan timeout)
{
ConsoleKeyInfo? keyInfo = null;
// We're not supposed to get here, but just in case
if (Console.IsInputRedirected)
{
return keyInfo;
}
var stopwatch = ExtendedStopwatch.StartNew();
do
{
if (Console.KeyAvailable)
{
keyInfo = Console.ReadKey(intercept: true);
break;
}
Thread.Sleep(500);
} while (stopwatch.Elapsed < timeout);
stopwatch.Stop();
return keyInfo;
}