Skip to content

Instantly share code, notes, and snippets.

@krishnabhargav
Created December 13, 2011 02:10
Show Gist options
  • Save krishnabhargav/1470125 to your computer and use it in GitHub Desktop.
Save krishnabhargav/1470125 to your computer and use it in GitHub Desktop.
Frequent class implementation
/// 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