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

@@ -1,5 +1,7 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using JetBrains.Annotations;
namespace Wox.Plugin
@@ -11,7 +13,13 @@ namespace Wox.Plugin
[NotifyPropertyChangedInvocator]
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));
}));
}
}
}