title: Declaring multiple event handlers does not work
body: <p>I have a page that can contain multiple user controls. Each user control has at least one button that invokes an event. I want to capture these events.</p>
  
  <p>I produced a test page - the results are that a single handler explicity set on the user control works, however a ForEach does not. Here's the code:</p>
  
  <pre><code>    protected void Page_Load(object sender, EventArgs e)
      {
          // This works
          JumpButton1.HasVisited += new EventHandler(JumpButton_HasVisited);
  
          // This does not work            
          this.Controls.OfType&lt;JumpButton&gt;()
          .ForEach(uc =&gt; uc.HasVisited += new EventHandler(JumpButton_HasVisited));
      }
  
      void JumpButton_HasVisited(object sender, EventArgs e)
      {
          Label1.Text = "Updated button: " + DateTime.Now;
      }
  </code></pre>
  
  <p>For information when I count the controls returned - a count of 1 is returned which would indicate that the controls are being found.</p>
  
  <p>Any ideas where I might be going wrong?</p>
  
  <hr>
  
  <h2>UPDATE 1</h2>
  
  <p>Here is an example using my own extension method to find the controls. I added a check to see if jumGroup contained any controls, and it does. However the handler still does not trigger.</p>
  
  <pre><code>        var jumpGroup = Page.FindControls&lt;JumpButton&gt;();
          foreach (var item in jumpGroup)
          {
              // This shows ID's
              Response.Write(item.ID);
          }
  
          jumpGroup.ForEach(uc =&gt; uc.HasVisited += new EventHandler(JumpGroup_HasVisited));
  </code></pre>
  
  <hr>
  
  <h2>UPDATE 2</h2>
  
  <p>Tracked the source of the problem but stil not sure why this doesn't work. IEnumerable extension method is at fault - when replaced by a foreach loop this works.</p>
  
  <pre><code>    public static IEnumerable&lt;T&gt; ForEach&lt;T&gt;(this IEnumerable&lt;T&gt; @this, Action&lt;T&gt; action)
      {
          @this.ThrowNull("@this");
          action.ThrowNull("action");
  
          foreach (T item in @this)
          {
              action(item);
              yield return item;
          }
      }
  </code></pre>