From d0ee08fa1137e81896b4c7d33d5b8466f5e447ee Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Wed, 28 Aug 2024 19:14:17 -0400 Subject: [PATCH 1/3] Add buttons and logic for rearranging tasks --- TwitchDownloaderWPF/PageQueue.xaml | 10 +++++++- TwitchDownloaderWPF/PageQueue.xaml.cs | 34 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/TwitchDownloaderWPF/PageQueue.xaml b/TwitchDownloaderWPF/PageQueue.xaml index 31733e35..c8054e1c 100644 --- a/TwitchDownloaderWPF/PageQueue.xaml +++ b/TwitchDownloaderWPF/PageQueue.xaml @@ -87,7 +87,15 @@ - + + - From c9cec6023eb471dfacafc6d0a47507efc9ab0df7 Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Wed, 28 Aug 2024 19:16:09 -0400 Subject: [PATCH 3/3] Fix potential race condition --- TwitchDownloaderWPF/PageQueue.xaml.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/TwitchDownloaderWPF/PageQueue.xaml.cs b/TwitchDownloaderWPF/PageQueue.xaml.cs index dc8a664a..a12fee62 100644 --- a/TwitchDownloaderWPF/PageQueue.xaml.cs +++ b/TwitchDownloaderWPF/PageQueue.xaml.cs @@ -290,9 +290,12 @@ private static void RemoveTask(TwitchTask task) return; } - if (!taskList.Remove(task)) + lock (taskLock) { - MessageBox.Show(Application.Current.MainWindow!, Translations.Strings.TaskCouldNotBeRemoved, Translations.Strings.UnknownErrorOccurred, MessageBoxButton.OK, MessageBoxImage.Error); + if (!taskList.Remove(task)) + { + MessageBox.Show(Application.Current.MainWindow!, Translations.Strings.TaskCouldNotBeRemoved, Translations.Strings.UnknownErrorOccurred, MessageBoxButton.OK, MessageBoxImage.Error); + } } }