using HardwareMonitorStatusWindow.Service; using Microsoft.Win32.TaskScheduler; using Serilog; using System; using System.Diagnostics; using Velopack; namespace HardwareMonitorStatusWindow.StatusWindow; internal class Program { [STAThread] public static void Main(string[] args) { if (args.Contains("--debug")) Debugger.Launch(); Log.Logger = new LoggerConfiguration().WriteTo.File("HardwareMonitorStatusWindow.log").CreateLogger(); Log.Information("Start"); var stopServiceHook = new VelopackHook(_ => { try { using var taskService = new TaskService(); Log.Information("Checking for task name: {name}", HardwareMonitorService.ScheduledTaskName); var existingTask = taskService.FindTask(HardwareMonitorService.ScheduledTaskName); Log.Information("Task: {existingTask}", existingTask); Log.Information("Stopping task"); existingTask?.Stop(); } catch (Exception exception) { // Ignored Log.Error(exception, ""); } }); VelopackApp.Build().OnBeforeUpdateFastCallback(stopServiceHook).OnBeforeUninstallFastCallback(stopServiceHook).SetLogger(new SerilogVelopackLogger()).Run(); var app = new App(); app.InitializeComponent(); app.Run(); Log.Information("End"); } }