Skip to content

Commit dbcb072

Browse files
committed
Remove the additional sync check. Let WPF handle it natively
1 parent 0c05308 commit dbcb072

File tree

2 files changed

+2
-21
lines changed

2 files changed

+2
-21
lines changed

SimpleViewModel/BaseClasses/BaseViewModel.cs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ namespace SimpleViewModel.BaseClasses;
1010
/// </summary>
1111
public class BaseViewModel : INotifyPropertyChanged
1212
{
13-
private readonly SynchronizationContext? _syncContext = SynchronizationContext.Current;
14-
1513
/// <inheritdoc/>
1614
public event PropertyChangedEventHandler? PropertyChanged;
1715

@@ -27,8 +25,7 @@ protected void SetProperty<T>(ref T reference, T value, [CallerMemberName] strin
2725
if (EqualityComparer<T>.Default.Equals(reference, value))
2826
return;
2927

30-
reference = value;
31-
RaisePropertyChanged(propertyName);
28+
PropertyChanged?.Invoke(this, new(propertyName));
3229
}
3330

3431
/// <summary>
@@ -38,22 +35,6 @@ protected void SetProperty<T>(ref T reference, T value, [CallerMemberName] strin
3835
protected virtual void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
3936
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
4037

41-
private void RaisePropertyChanged(string propertyName)
42-
{
43-
var handler = PropertyChanged;
44-
if (handler is null)
45-
return;
46-
47-
if (_syncContext != null)
48-
{
49-
_syncContext.Post(_ => handler(this, new(propertyName)), null);
50-
}
51-
else
52-
{
53-
handler(this, new(propertyName));
54-
}
55-
}
56-
5738
/// <summary>
5839
/// Called when a generated command throws.
5940
/// Default behavior preserves stack and crashes (correct for debugging).

SimpleViewModel/SimpleViewModel.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1111
<PackageId>SimpleViewModel</PackageId>
12-
<Version>0.9.8.0</Version>
12+
<Version>0.9.8.1</Version>
1313
<Authors>Derek Gooding</Authors>
1414
<Company>Derek Gooding</Company>
1515
<Description>

0 commit comments

Comments
 (0)