Beispiel #1
0
 private static bool ConsoleEventCallback(int eventType)
 {
     if (eventType == 2)
     {
         ConsoleExiting?.Invoke(ConsoleExitReason.WindowClosed);
     }
     return(false);
 }
        static Helper()
        {
            RunProcessAsync(@"rundll32", @"c:\windows\system32\dfshim.dll CleanOnlineAppCache");

            //"If the directory already exists, this method does not create a new directory, but it returns a DirectoryInfo object for the existing directory."
            Directory.CreateDirectory(_localLogPath);
            Directory.CreateDirectory(_localRefFilePath);

            //fire an event when program closing by user operations while running in console mode.
            Console.CancelKeyPress += (o, e) => ConsoleExiting?.Invoke(ConsoleExitReason.CancelKeyPressed);
            handler = new ConsoleEventDelegate(ConsoleEventCallback);
            SetConsoleCtrlHandler(handler, true);
        }