mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Duplicate instance check
This commit is contained in:
1 parent
7526e4b239
commit
bf9a30bea2
1 file changed
+18
-1
@@ -1,8 +1,13 @@
|
||||
using System.Windows;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.ViewModels;
|
||||
using Autofac;
|
||||
using Caliburn.Micro;
|
||||
using Caliburn.Micro.Autofac;
|
||||
using Application = System.Windows.Application;
|
||||
using MessageBox = System.Windows.Forms.MessageBox;
|
||||
|
||||
namespace Artemis
|
||||
{
|
||||
@@ -10,6 +15,7 @@ namespace Artemis
|
||||
{
|
||||
public ArtemisBootstrapper()
|
||||
{
|
||||
CheckDuplicateInstances();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
@@ -27,5 +33,16 @@ namespace Artemis
|
||||
{
|
||||
DisplayRootViewFor<SystemTrayViewModel>();
|
||||
}
|
||||
|
||||
private void CheckDuplicateInstances()
|
||||
{
|
||||
var processes = Process.GetProcesses();
|
||||
if (processes.Count(p => p.ProcessName == "Artemis") < 2)
|
||||
return;
|
||||
|
||||
MessageBox.Show("An instance of Artemis is already running (check your system tray).",
|
||||
"Artemis (╯°□°)╯︵ ┻━┻", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user