Improved cross threaded invocation.
This commit is contained in:
parent
766d427b19
commit
a44c46333f
5 changed files with 149 additions and 55 deletions
|
|
@ -4,15 +4,13 @@ using System.Threading;
|
|||
|
||||
namespace LibationWinForms
|
||||
{
|
||||
public abstract class AsyncNotifyPropertyChanged : INotifyPropertyChanged
|
||||
public abstract class AsyncNotifyPropertyChanged : SynchronizeInvoker, INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private CrossThreadSync<PropertyChangedEventArgs> ThreadSync { get; } = new CrossThreadSync<PropertyChangedEventArgs>();
|
||||
|
||||
public AsyncNotifyPropertyChanged()
|
||||
=>ThreadSync.ObjectReceived += (_, args) => PropertyChanged?.Invoke(this, args);
|
||||
public AsyncNotifyPropertyChanged() { }
|
||||
|
||||
protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
|
||||
=> ThreadSync.Post(new PropertyChangedEventArgs(propertyName));
|
||||
=>BeginInvoke(PropertyChanged, new object[] { this, new PropertyChangedEventArgs(propertyName) });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue