From 068ca56a5e30e8883f0e6d33be2d4ef37c379f9b Mon Sep 17 00:00:00 2001 From: alkl58 Date: Sat, 29 Oct 2022 13:14:34 +0200 Subject: [PATCH] Prevent running multiple Instances --- NotEnoughAV1Encodes/MainWindow.xaml.cs | 9 +++++++++ NotEnoughAV1Encodes/resources/lang/Strings.de.resx | 3 +++ NotEnoughAV1Encodes/resources/lang/Strings.fr-FR.resx | 3 +++ NotEnoughAV1Encodes/resources/lang/Strings.resx | 3 +++ 4 files changed, 18 insertions(+) diff --git a/NotEnoughAV1Encodes/MainWindow.xaml.cs b/NotEnoughAV1Encodes/MainWindow.xaml.cs index 877f151..1f1eb12 100644 --- a/NotEnoughAV1Encodes/MainWindow.xaml.cs +++ b/NotEnoughAV1Encodes/MainWindow.xaml.cs @@ -56,6 +56,15 @@ public MainWindow() } LocalizeDictionary.Instance.Culture = settingsDB.CultureInfo; + + var exists = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Count() > 1; + + if (exists) + { + MessageBox.Show(LocalizedStrings.Instance["MessageAlreadyRunning"], "", MessageBoxButton.OK, MessageBoxImage.Stop); + Process.GetCurrentProcess().Kill(); + return; + } } #region Startup diff --git a/NotEnoughAV1Encodes/resources/lang/Strings.de.resx b/NotEnoughAV1Encodes/resources/lang/Strings.de.resx index f4c0a85..0c8e351 100644 --- a/NotEnoughAV1Encodes/resources/lang/Strings.de.resx +++ b/NotEnoughAV1Encodes/resources/lang/Strings.de.resx @@ -536,4 +536,7 @@ Please download and extract 7-zip to the following path: Fehler: Keine Ausgabedatei erkannt + + Es wird bereits eine Instanz der Anwendung ausgeführt. + \ No newline at end of file diff --git a/NotEnoughAV1Encodes/resources/lang/Strings.fr-FR.resx b/NotEnoughAV1Encodes/resources/lang/Strings.fr-FR.resx index 108305f..f513dce 100644 --- a/NotEnoughAV1Encodes/resources/lang/Strings.fr-FR.resx +++ b/NotEnoughAV1Encodes/resources/lang/Strings.fr-FR.resx @@ -536,4 +536,7 @@ Please download and extract 7-zip to the following path: Erreur : Aucune sortie de fichier détectée + + Une instance de l'application est déjà en cours d'exécution. + \ No newline at end of file diff --git a/NotEnoughAV1Encodes/resources/lang/Strings.resx b/NotEnoughAV1Encodes/resources/lang/Strings.resx index 219eb45..49af292 100644 --- a/NotEnoughAV1Encodes/resources/lang/Strings.resx +++ b/NotEnoughAV1Encodes/resources/lang/Strings.resx @@ -539,4 +539,7 @@ Please download and extract 7-zip to the following path: Input and Output Path are the same! + + An instance of the application is already running. + \ No newline at end of file