From 8d6dca93682deb61ed16b14c555fcd800635af19 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 13 Feb 2025 09:18:32 -0600 Subject: [PATCH] Lock both lists at the same time --- .../Microsoft.CmdPal.UI.ViewModels/ListViewModel.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ListViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ListViewModel.cs index a6a548a0f8c8..8161d2d64215 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ListViewModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/ListViewModel.cs @@ -29,6 +29,8 @@ public partial class ListViewModel : PageViewModel private readonly ExtensionObject _model; + private readonly Lock _listLock = new(); + public event TypedEventHandler? ItemsUpdated; // Remember - "observable" properties from the model (via PropChanged) @@ -82,7 +84,7 @@ protected override void OnFilterUpdated(string filter) else { // But for all normal pages, we should run our fuzzy match on them. - lock (FilteredItems) + lock (_listLock) { ApplyFilterUnderLock(); } @@ -117,7 +119,7 @@ private void FetchItems() } } - lock (Items) + lock (_listLock) { // Now that we have new ViewModels for everything from the // extension, smartly update our list of VMs @@ -138,7 +140,7 @@ private void FetchItems() Task.Factory.StartNew( () => { - lock (FilteredItems) + lock (_listLock) { // Now that our Items contains everything we want, it's time for us to // re-evaluate our Filter on those items.