mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 09:43:46 +00:00
UI - Ensure proper restart and shutdown
This commit is contained in:
parent
c62997ca41
commit
002ae29638
@ -348,7 +348,7 @@ namespace Artemis.Core.Services
|
|||||||
// Device providers cannot be disabled at runtime, restart the application
|
// Device providers cannot be disabled at runtime, restart the application
|
||||||
if (plugin is DeviceProvider)
|
if (plugin is DeviceProvider)
|
||||||
{
|
{
|
||||||
CurrentProcessUtilities.RestartSelf();
|
CurrentProcessUtilities.Shutdown(2, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,16 +11,24 @@ namespace Artemis.Core.Utilities
|
|||||||
return Process.GetCurrentProcess().MainModule.FileName;
|
return Process.GetCurrentProcess().MainModule.FileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RestartSelf()
|
public static void Shutdown(int delay, bool restart)
|
||||||
{
|
{
|
||||||
|
// Always kill the process after the delay has passed, with all the plugins a graceful shutdown cannot be guaranteed
|
||||||
|
var arguments = "-Command \"& {Start-Sleep -s " + delay + "; (Get-Process 'Artemis.UI').kill()}";
|
||||||
|
// If restart is required, start the executable again after the process was killed
|
||||||
|
if (restart)
|
||||||
|
arguments = "-Command \"& {Start-Sleep -s " + delay + "; (Get-Process 'Artemis.UI').kill(); Start-Process -FilePath '" + GetCurrentLocation() + "'}\"";
|
||||||
|
|
||||||
var info = new ProcessStartInfo
|
var info = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
Arguments = "/C choice /C Y /N /D Y /T 5 & START /wait taskkill /f /im \"Artemis.UI.exe\" & START \"\" \"" + GetCurrentLocation() + "\"",
|
Arguments = arguments,
|
||||||
WindowStyle = ProcessWindowStyle.Hidden,
|
WindowStyle = ProcessWindowStyle.Hidden,
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
FileName = "cmd.exe"
|
FileName = "PowerShell.exe"
|
||||||
};
|
};
|
||||||
Process.Start(info);
|
Process.Start(info);
|
||||||
|
|
||||||
|
// Also attempt a graceful shutdown on the UI thread
|
||||||
Execute.OnUIThread(() => Application.Current.Shutdown());
|
Execute.OnUIThread(() => Application.Current.Shutdown());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Artemis.Core.Services;
|
using Artemis.Core.Services;
|
||||||
using Artemis.Core.Services.Interfaces;
|
using Artemis.Core.Services.Interfaces;
|
||||||
|
using Artemis.Core.Utilities;
|
||||||
using Artemis.UI.Events;
|
using Artemis.UI.Events;
|
||||||
using Artemis.UI.Screens.Splash;
|
using Artemis.UI.Screens.Splash;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
@ -57,7 +58,7 @@ namespace Artemis.UI.Screens
|
|||||||
|
|
||||||
public void TrayExit()
|
public void TrayExit()
|
||||||
{
|
{
|
||||||
Application.Current.Shutdown();
|
CurrentProcessUtilities.Shutdown(2, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowSplashScreen()
|
private void ShowSplashScreen()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user