Beispiel #1
0
 static void _cancelHandler(object sender, ConsoleCancelEventArgs args)
 {
     Console.SetCursorPosition(0, Console.CursorTop);
     Console.WriteLine("Program canceled by user");
     args.Cancel = true;
     Arch.Cancel();
 }
Beispiel #2
0
        static void Main(String[] Arguments)
        {
            DateTime StartTime = DateTime.Now;

            Arguments = new String[3];

            Arguments[0] = "compress";
            Arguments[1] = @"D:\1.bin";
            Arguments[2] = @"D:\2.bin.gz";

            try
            {
                using (Archiver Archiver = new Archiver(new ArchiverParameters(Arguments)))
                {
                    Console.CancelKeyPress += (o, e) =>
                    {
                        e.Cancel = true;

                        Archiver.Cancel();
                    };

                    Archiver.Process();
                }
            }
            catch (Exception E)
            {
                Console.WriteLine($"Ошибка. {E.Message}");
                Console.ReadKey();

                Environment.Exit(1);
            }

            Console.WriteLine($"Время выполнения = {(DateTime.Now - StartTime).TotalSeconds} секунд.");
            Console.ReadKey();

            Environment.Exit(0);
        }