diff --git a/Artemis/Artemis/ArtemisBootstrapper.cs b/Artemis/Artemis/ArtemisBootstrapper.cs index 36a84f7ce..e6f178e51 100644 --- a/Artemis/Artemis/ArtemisBootstrapper.cs +++ b/Artemis/Artemis/ArtemisBootstrapper.cs @@ -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(); } + + 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(); + } } } \ No newline at end of file