You would need to break the above out in to private/public members so you don't get recursive problems:
private float _inverseMass;
public float inverseMass
{
get { return this._inverseMass; }
set { this._inverseMass = value; onMassChanged(); }
}
However, have you looked in to the INotifyPropertyChanged
interface? It does pretty much what you're looking for, and depending on what you're writing it could be supported natively.
public class MyClass : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String property)
{
var event = this.PropertyChanged;
if (event != null)
{
event(this, new PropertyChangedEventArgs(property));
}
}
private float _inverseMass;
public float inverseMass
{
get { return this._inverseMass; }
set { this._inverseMass = value; NotifyPropertyChanged("inverseMass"); }
}
}