Skip to content

Commit

Permalink
Prevent running multiple Instances
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkl58 committed Oct 29, 2022
1 parent 45877b7 commit 068ca56
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions NotEnoughAV1Encodes/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions NotEnoughAV1Encodes/resources/lang/Strings.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -536,4 +536,7 @@ Please download and extract 7-zip to the following path:
<data name="OutputErrorDetected" xml:space="preserve">
<value>Fehler: Keine Ausgabedatei erkannt</value>
</data>
<data name="MessageAlreadyRunning" xml:space="preserve">
<value>Es wird bereits eine Instanz der Anwendung ausgeführt.</value>
</data>
</root>
3 changes: 3 additions & 0 deletions NotEnoughAV1Encodes/resources/lang/Strings.fr-FR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -536,4 +536,7 @@ Please download and extract 7-zip to the following path:
<data name="OutputErrorDetected" xml:space="preserve">
<value>Erreur : Aucune sortie de fichier détectée</value>
</data>
<data name="MessageAlreadyRunning" xml:space="preserve">
<value>Une instance de l'application est déjà en cours d'exécution.</value>
</data>
</root>
3 changes: 3 additions & 0 deletions NotEnoughAV1Encodes/resources/lang/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -539,4 +539,7 @@ Please download and extract 7-zip to the following path:
<data name="MessageSameInputOutput" xml:space="preserve">
<value>Input and Output Path are the same!</value>
</data>
<data name="MessageAlreadyRunning" xml:space="preserve">
<value>An instance of the application is already running.</value>
</data>
</root>

0 comments on commit 068ca56

Please sign in to comment.