Try stopping service task before upgrade/uninstall
All checks were successful
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 54s
All checks were successful
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 54s
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Serilog;
|
||||
using HardwareMonitorStatusWindow.Service;
|
||||
using Microsoft.Win32.TaskScheduler;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Velopack;
|
||||
@@ -17,7 +19,30 @@ internal class Program
|
||||
|
||||
Log.Information("Start");
|
||||
|
||||
VelopackApp.Build().SetLogger(new SerilogVelopackLogger()).Run();
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user