Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            Console.CancelKeyPress += Console_CancelKeyPress;

            try
            {
                var arguments = new CommandLine.Parser().Parse(args);
                _processor = GetProcessor(arguments);

                var stopwatch = Stopwatch.StartNew();
                _processor.Run();
                stopwatch.Stop();

                Console.WriteLine($"Work done in {stopwatch.ElapsedMilliseconds} ms");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                _processor?.Cancel();
            }

            Console.ReadKey();
        }
Exemplo n.º 2
0
 private static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e)
 {
     if (e.SpecialKey == ConsoleSpecialKey.ControlC)
     {
         e.Cancel = true;
         _processor.Cancel();
     }
 }