title: Why isn't this causing an infinite loop of events?
body: <p>I have a simple application that reverses any text typed to it in another textbox. The catch is, you can modify either textbox and the changes will be (literally) reflected in the other.</p>
  
  <p>I wrote this code, believing for it to cause problems.</p>
  
  <pre><code>private void realText_TextChanged(object sender, EventArgs e)
  {
      mirrorText.Text = mirror(realText.Text);
  }
  
  private void mirrorText_TextChanged(object sender, EventArgs e)
  {
      realText.Text = mirror(mirrorText.Text);
  }
  
  private string mirror(string text)
  {
      return new string(text.Reverse().ToArray()).Replace("\n\r", "\r\n");
  }
  </code></pre>
  
  <p>I then tried it out, believing that it would cause an infinite loop (<code>realText</code> changes <code>mirrorText</code>, another event happens, <code>mirrorText</code> changes <code>realText</code>, etc). However, nothing except the intended behavior happened.</p>
  
  <p>I'm of course happy about this, I could just leave it here. <em>Or could I?</em></p>
  
  <p>I'm quite sure the <code>TextChanged</code> event is supposed to be fired whenever <code>Text</code> is changed. Is this intended behavior of some error protection in the events, or was I just lucky? Can this code misbehave on another computer, with other build settings, etc? It can be easily fixed:</p>
  
  <pre><code>private void realText_TextChanged(object sender, EventArgs e)
  {
      if (realText.Focused)
      {
          mirrorText.Text = Mirror(realText.Text);
      }
  }
  </code></pre>
  
  <p>I'll probably do it anyway to be safe, but is it <strong>required</strong> to check this? (I'm not even going to ask if it's recommended.)</p>