static void Main(string[] args) { var test = new TestsSample(); test.Setup(); test.DoTest(); Console.WriteLine("Press ESC to stop"); do { while (!Console.KeyAvailable) { // Do something } } while (Console.ReadKey(true).Key != ConsoleKey.Escape); }