Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock both lists at the same time #422

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public partial class ListViewModel : PageViewModel

private readonly ExtensionObject<IListPage> _model;

private readonly Lock _listLock = new();

public event TypedEventHandler<ListViewModel, object>? ItemsUpdated;

// Remember - "observable" properties from the model (via PropChanged)
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down