Fixed issue with wpf marshalling events to a non UI thread

This commit is contained in:
Divyansh
2020-04-02 10:10:36 -07:00
parent ce2bf5ac53
commit 5a13850043
2 changed files with 10 additions and 13 deletions

View File

@@ -13,25 +13,14 @@ using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation; using Windows.UI.Xaml.Navigation;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
namespace PowerLauncher.UI namespace PowerLauncher.UI
{ {
public sealed partial class LauncherControl : UserControl public sealed partial class LauncherControl : UserControl
{ {
List<SearchApp> SearchResults;
public LauncherControl() public LauncherControl()
{ {
this.InitializeComponent(); this.InitializeComponent();
ShellBarShadow.Receivers.Add(ShadowReceiverGrid); ShellBarShadow.Receivers.Add(ShadowReceiverGrid);
} }
} }
public class SearchApp
{
public string Title { get; set; }
public string Icon { get; set; }
public string Path { get; set; }
}
} }

View File

@@ -1,5 +1,7 @@
using System.ComponentModel; using System;
using System.ComponentModel;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Windows;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Wox.Plugin namespace Wox.Plugin
@@ -11,7 +13,13 @@ namespace Wox.Plugin
[NotifyPropertyChangedInvocator] [NotifyPropertyChangedInvocator]
protected void OnPropertyChanged([CallerMemberName] string propertyName = null) protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{ {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); if (Application.Current.Dispatcher.CheckAccess())
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
else
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}));
} }
} }
} }