예제 #1
0
    private static int Main()
    {
        // Create default logger
        CreateLogger(null);

        // Create a 15s timer to keep the system from going to sleep
        // TODO: The system occasionally still goes to sleep when debugging, why?
        KeepAwake.PreventSleep();
        using System.Timers.Timer keepAwakeTimer = new(15 * 1000);
        keepAwakeTimer.Elapsed  += KeepAwake.OnTimedEvent;
        keepAwakeTimer.AutoReset = true;
        keepAwakeTimer.Start();

        // Create the commandline and execute commands
        RootCommand rootCommand = CommandLineOptions.CreateRootCommand();
        int         ret         = rootCommand.Invoke(Environment.CommandLine);

        // Stop the timer
        keepAwakeTimer.Stop();
        keepAwakeTimer.Dispose();
        KeepAwake.AllowSleep();

        // Flush the logs
        Log.CloseAndFlush();

        return(ret);
    }
예제 #2
0
 void Application_End(object sender, EventArgs e)
 {
     // Force the App to be restarted immediately
     Log.WriteTextAsync("App stopped").Wait();
     KeepAwake.PingServer();
 }