From 89e06436724608df929699caea09e6232d6fe6cc Mon Sep 17 00:00:00 2001 From: lay295 Date: Tue, 16 Nov 2021 01:00:11 -0500 Subject: [PATCH] Prevent multiple instances --- TwitchArchiverWPF/MainWindow.xaml | 15 ++++++++------- TwitchArchiverWPF/MainWindow.xaml.cs | 5 +++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/TwitchArchiverWPF/MainWindow.xaml b/TwitchArchiverWPF/MainWindow.xaml index 504072f..7d0440a 100644 --- a/TwitchArchiverWPF/MainWindow.xaml +++ b/TwitchArchiverWPF/MainWindow.xaml @@ -10,10 +10,11 @@ - + + - + @@ -25,12 +26,12 @@ - + - - - - + + + + diff --git a/TwitchArchiverWPF/MainWindow.xaml.cs b/TwitchArchiverWPF/MainWindow.xaml.cs index 0d3c637..917ff87 100644 --- a/TwitchArchiverWPF/MainWindow.xaml.cs +++ b/TwitchArchiverWPF/MainWindow.xaml.cs @@ -60,6 +60,11 @@ public partial class MainWindow : Window public MainWindow() { + String processName = Process.GetCurrentProcess().ProcessName; + + if (Process.GetProcesses().Count(p => p.ProcessName == processName) > 1) + System.Windows.Application.Current.Shutdown(); + if (!File.Exists("ffmpeg.exe")) FFmpegDownloader.GetLatestVersion(FFmpegVersion.Official);