示例#1
0
文件: Program.cs 项目: ciwik/gzipper
        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();
        }
示例#2
0
文件: Program.cs 项目: ciwik/gzipper
 private static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e)
 {
     if (e.SpecialKey == ConsoleSpecialKey.ControlC)
     {
         e.Cancel = true;
         _processor.Cancel();
     }
 }