I want to stop the whole do-while loop by using space and write out my WriteLine, but it doesn't do anything on pressing spacebar. I think it's something to do with Thread.Sleep, maybe It doesn't allow user input while on Sleep. I would be really happy if someone could enlighten me why this doesn't work
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace casinov2
{
class Program
{
static void Main(string[] args)
{
int x=3;
int y = 15;
int[] elemek = new int[7];
do{
while (!Console.KeyAvailable){
for (int i = 0; i < 5; i++){
Console.Clear();
Console.SetCursorPosition(x, y);
x++;
Console.WriteLine("{0:██}{1:██}{2:██}", elemek[i], elemek[i + 1], elemek[i + 2]);
System.Threading.Thread.Sleep(100);
if (i >= 4){
for (int j = 0; j < 5; j++){
Console.Clear();
Console.SetCursorPosition(x, y);
x--;
Console.WriteLine("{0:██}{1:██}{2:██}", elemek[i], elemek[i + 1], elemek[i + 2]);
System.Threading.Thread.Sleep(100);
}
i = -1;
}
}
}
} while (Console.ReadKey(true).Key != ConsoleKey.Spacebar);
Console.WriteLine("ready");
Console.ReadLine();
}
}
}