-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly handle PropertyChanged event raisers that return Task (#346)
* Properly handle PropertyChanged event raisers that return Task * added delay option to EventTester.TestProperty to eliminate race condition when property changed raiser returns Task.
- Loading branch information
1 parent
00141e5
commit e82d63b
Showing
4 changed files
with
66 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
TestAssemblies/AssemblyToProcess/ClassWithTaskReturningPropertyChangedNotifier.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.ComponentModel; | ||
using System.Runtime.CompilerServices; | ||
using System.Threading.Tasks; | ||
|
||
public class ClassWithTaskReturningPropertyChangedNotifier : INotifyPropertyChanged | ||
{ | ||
public string Property1 { get; set; } | ||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
public virtual Task RaisePropertyChanged([CallerMemberName] string whichProperty = "") | ||
{ | ||
var changedArgs = new PropertyChangedEventArgs(whichProperty); | ||
return RaisePropertyChanged(changedArgs); | ||
} | ||
|
||
private async Task RaisePropertyChanged(PropertyChangedEventArgs changedArgs) | ||
{ | ||
void raiseChange() | ||
{ | ||
PropertyChanged?.Invoke(this, changedArgs); | ||
} | ||
|
||
await Task.Run(() => raiseChange()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters