From 1040a347c6d666433ea3122a8424dd00459c3ac5 Mon Sep 17 00:00:00 2001 From: Mbucari <37587114+Mbucari@users.noreply.github.com> Date: Thu, 2 Sep 2021 21:04:16 -0600 Subject: [PATCH] Fixed cross thread bug and Enumerable change bug. --- LibationWinForms/Dialogs/RemoveBooksDialog.cs | 2 +- LibationWinForms/Form1.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LibationWinForms/Dialogs/RemoveBooksDialog.cs b/LibationWinForms/Dialogs/RemoveBooksDialog.cs index 139612c5..7496df2b 100644 --- a/LibationWinForms/Dialogs/RemoveBooksDialog.cs +++ b/LibationWinForms/Dialogs/RemoveBooksDialog.cs @@ -58,7 +58,7 @@ namespace LibationWinForms.Dialogs { var removedBooks = await LibraryCommands.FindInactiveBooks((account) => new WinformResponder(account), _libraryBooks, _accounts); - var removable = _removableGridEntries.Where(rge => removedBooks.Any(rb => rb.Book.AudibleProductId == rge.AudibleProductId)); + var removable = _removableGridEntries.Where(rge => removedBooks.Any(rb => rb.Book.AudibleProductId == rge.AudibleProductId)).ToList(); if (!removable.Any()) return; diff --git a/LibationWinForms/Form1.cs b/LibationWinForms/Form1.cs index deeebcae..b17befb9 100644 --- a/LibationWinForms/Form1.cs +++ b/LibationWinForms/Form1.cs @@ -151,7 +151,7 @@ namespace LibationWinForms { if (currProductsGrid != null) { - gridPanel.Controls.Remove(currProductsGrid); + gridPanel.UIThread(() => gridPanel.Controls.Remove(currProductsGrid)); currProductsGrid.VisibleCountChanged -= setVisibleCount; currProductsGrid.Dispose(); }