From 48ca7904f1b503cb3b53e38f8bbda26914be496c Mon Sep 17 00:00:00 2001 From: tom-englert Date: Sat, 28 Sep 2024 11:45:14 +0200 Subject: [PATCH] Multiple Refresh calls sholud just trigger one refresh cycle. --- ILSpy/AssemblyTree/AssemblyTreeModel.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ILSpy/AssemblyTree/AssemblyTreeModel.cs b/ILSpy/AssemblyTree/AssemblyTreeModel.cs index e5fe8e51d..60bda754f 100644 --- a/ILSpy/AssemblyTree/AssemblyTreeModel.cs +++ b/ILSpy/AssemblyTree/AssemblyTreeModel.cs @@ -67,6 +67,7 @@ namespace ICSharpCode.ILSpy.AssemblyTree AssemblyListPane? activeView; AssemblyListTreeNode? assemblyListTreeNode; + private readonly DispatcherThrottle refreshThrottle; readonly NavigationHistory history = new(); private bool isNavigatingHistory; @@ -83,6 +84,8 @@ namespace ICSharpCode.ILSpy.AssemblyTree var selectionChangeThrottle = new DispatcherThrottle(DispatcherPriority.Input, TreeView_SelectionChanged); SelectedItems.CollectionChanged += (_, _) => selectionChangeThrottle.Tick(); + + refreshThrottle = new DispatcherThrottle(DispatcherPriority.Background, RefreshInternal); } private void Settings_PropertyChanged(object? sender, PropertyChangedEventArgs e) @@ -897,6 +900,11 @@ namespace ICSharpCode.ILSpy.AssemblyTree } public void Refresh() + { + refreshThrottle.Tick(); + } + + private void RefreshInternal() { using (Keyboard.FocusedElement.PreserveFocus()) {