- Add functions

- Code improvements
This commit is contained in:
Stone-Red-Code
2021-11-19 20:49:55 +01:00
parent 812b780942
commit 2a7e8074ba
27 changed files with 356 additions and 156 deletions
@@ -0,0 +1,36 @@
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);
}
}
}
}