From d6fce7c0993936e1de2ca74bf8f119ce631ab8bf Mon Sep 17 00:00:00 2001 From: ryanbodrug-microsoft <56318517+ryanbodrug-microsoft@users.noreply.github.com> Date: Wed, 25 Mar 2020 16:34:56 -0700 Subject: [PATCH] removing locks from the ResultListBox code behind file. All callbacks are accessed from the Main/UI thread. --- .../launcher/Wox/ResultListBox.xaml.cs | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/modules/launcher/Wox/ResultListBox.xaml.cs b/src/modules/launcher/Wox/ResultListBox.xaml.cs index 6b46644900..1f8b1a1513 100644 --- a/src/modules/launcher/Wox/ResultListBox.xaml.cs +++ b/src/modules/launcher/Wox/ResultListBox.xaml.cs @@ -6,7 +6,6 @@ namespace Wox { public partial class ResultListBox { - protected object _lock = new object(); private Point _lastpos; private ListBoxItem curItem = null; public ResultListBox() @@ -24,34 +23,25 @@ namespace Wox private void OnMouseEnter(object sender, MouseEventArgs e) { - lock(_lock) - { - curItem = (ListBoxItem)sender; - var p = e.GetPosition((IInputElement)sender); - _lastpos = p; - } + curItem = (ListBoxItem)sender; + var p = e.GetPosition((IInputElement)sender); + _lastpos = p; } private void OnMouseMove(object sender, MouseEventArgs e) { - lock(_lock) + var p = e.GetPosition((IInputElement)sender); + if (_lastpos != p) { - var p = e.GetPosition((IInputElement)sender); - if (_lastpos != p) - { - ((ListBoxItem)sender).IsSelected = true; - } + ((ListBoxItem)sender).IsSelected = true; } } private void ListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e) { - lock(_lock) + if (curItem != null) { - if (curItem != null) - { - curItem.IsSelected = true; - } + curItem.IsSelected = true; } } }