From 557adc7bce78833e98ae03e0c8c167a82ea68b76 Mon Sep 17 00:00:00 2001 From: prozolic <42107886+prozolic@users.noreply.github.com> Date: Sat, 24 Feb 2024 21:26:54 +0900 Subject: [PATCH] Add lock to TryGetValue --- src/ObservableCollections/ObservableHashSet.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ObservableCollections/ObservableHashSet.cs b/src/ObservableCollections/ObservableHashSet.cs index 4734174..8e2e1d4 100644 --- a/src/ObservableCollections/ObservableHashSet.cs +++ b/src/ObservableCollections/ObservableHashSet.cs @@ -185,7 +185,10 @@ public void Clear() public bool TryGetValue(T equalValue, [MaybeNullWhen(false)] out T actualValue) { - return set.TryGetValue(equalValue, out actualValue); + lock(SyncRoot) + { + return set.TryGetValue(equalValue, out actualValue); + } } #endif