예제 #1
0
 private static bool ConsoleEventCallback(int eventType)
 {
     if (eventType == 2)
     {
         ConsoleExiting?.Invoke(ConsoleExitReason.WindowClosed);
     }
     return(false);
 }
예제 #2
0
        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);
        }