Files
YesNt-Interpreter/YesNt-Interpreter/Utilities/ConsoleExtentions.cs
T
Stone-Red-Code 68a9bde5d9 - Add tasks
- Add check if file exist
- Improved code structure
2021-10-09 20:23:28 +02:00

36 lines
966 B
C#

using System;
using System.Diagnostics;
using System.Threading;
namespace YesNt.Interpreter.Utilities
{
internal static class ConsoleExtentions
{
public static char ReadKey(RuntimeInformation runtimeInformation)
{
while (!runtimeInformation.Stop)
{
if (Console.KeyAvailable)
{
return Console.ReadKey().KeyChar;
}
Thread.Sleep(10);
}
return ' ';
}
public static void Sleep(int millisecondsTimeout, RuntimeInformation runtimeInformation)
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
while (!runtimeInformation.Stop)
{
if (stopwatch.ElapsedMilliseconds > millisecondsTimeout)
{
return;
}
Thread.Sleep(10);
}
}
}
}