private static void Run() { Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress); Console.WriteLine("Press 'X' to quit"); ImportService.startSync(); while (true) { if (Console.ReadKey(true).Key == ConsoleKey.X) { Console_CancelKeyPress(null, null); break; } ; } }
static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e) { ImportService.stopSync(); Console.WriteLine("Sync Stop"); }