Created
December 13, 2011 02:10
-
-
Save krishnabhargav/1470125 to your computer and use it in GitHub Desktop.
Frequent class implementation
This file contains hidden or 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
/// Krishna Vangapandu | |
public class Frequent : INotifyPropertyChanged | |
{ | |
private string _property; | |
private readonly StringMessageThrottler _stringMessageThrottler; | |
public Frequent() | |
{ | |
//Create a new message throttler. The implementation for this would be shown later. | |
_stringMessageThrottler = new StringMessageThrottler(); | |
//subscribe on the throttler and when received a string, raise property changed event. | |
_stringMessageThrottler.Subscribe(s => PropertyChanged(this, new PropertyChangedEventArgs(s))); | |
} | |
public string Property | |
{ | |
get { return _property; } | |
set | |
{ | |
_property = value; | |
OnPropertyChanged("Property"); | |
} | |
} | |
public event PropertyChangedEventHandler PropertyChanged = delegate { }; | |
protected void OnPropertyChanged(string property) | |
{ | |
//when a property changes, simply publish it on the throttler. | |
_stringMessageThrottler.Publish(property); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment