title: Just how slow is this? INotifyPropertyChanged using the StackTrace
body: <p>Today, I came across an interesting method of implementing the INotifyPropertyChanged interface. Instead of passing a string name of the property changed, or a lambda expression, we can simply call RaisePropertyChanged(); from the setter, mark that the call is parameterless. This is the code in the RaisePropertyChanged() method:</p>
  
  <pre><code>public virtual void RaisePropertyChanged()
  {
      var frames = new System.Diagnostics.StackTrace();
      for (var i = 0; i &lt; frames.FrameCount; i++)
      {
          var frame = frames.GetFrame(i).GetMethod() as MethodInfo;
          if (frame != null)
              if (frame.IsSpecialName &amp;&amp; frame.Name.StartsWith("set_"))
              {
                  RaisePropertyChanged(frame.Name.Substring(4));
                  return;
              }
      }
      throw new InvalidOperationException("NotifyPropertyChanged() can only by invoked within a property setter.");
  }
  </code></pre>
  
  <p>And this is a property that will notify its dependants of its change:</p>
  
  <pre><code>public string MyProperty
  {
      get { return _myField; }
      set
      {
          _myField= value;
          RaisePropertyChanged();
      }
  }
  </code></pre>
  
  <p>While I find this approach interesting, I think the performance penalty could be serious in case the property changed often... or if every property in our application used this approach to notify of its change.</p>
  
  <p>I'd like to hear your opinions. (there is no longer the community-wiki checkbox?)
  Would this approach be <em>very</em> inefficient?</p>
  
  <p>Source: <a href="http://csharperimage.jeremylikness.com/2010/12/jounce-part-8-raising-property-changed.html" rel="nofollow">Article where this approach is presented</a></p>