I wish to run an event which will occur on some counter change, e.g. every time
int counter;
changes its value, the event is raised. I have something like from MSDN:
public class CounterChange:INotifyPropertyChanged
{
private int counter;
// Declare the event
public event PropertyChangedEventHandler PropertyChanged;
public CounterChange()
{
}
public CounterChange(int value)
{
this.counter = value;
}
public int Counter
{
get { return counter; }
set
{
counter = value;
// Call OnPropertyChanged whenever the property is updated
OnPropertyChanged("Counter");
}
}
// Create the OnPropertyChanged method to raise the event
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if(handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}
}
But have no idea what next. How to raise incrementation from program, and connect method to these event.