title: How does EventHandler with anonymous methods work?
body: <p>Presently, I have a windows form that is receiving data from a named pipe asynchronously.  To avoid getting the "Cross thread operation not valid: Control 'myTextBox' accessed from a thread other than the thread it was created on" I am using an anonymous method (see <a href="http://www.codeproject.com/Articles/28485/Beginners-Guide-to-Threading-in-NET-Part-of-n" rel="nofollow">http://www.codeproject.com/Articles/28485/Beginners-Guide-to-Threading-in-NET-Part-of-n</a>):</p>
  
  <pre><code>            // Pass message back to calling form
              if (this.InvokeRequired)
              {
                  // Create and invoke an anonymous method
                  this.Invoke(new EventHandler(delegate
                  {
                      myTextBox.Text = stringData;
                  }));
              }
              else
                  myTextBox.Text = stringData;
  </code></pre>
  
  <p>My question is, what does the "new EventHandler(delegate" line do?  Does it create a delegate of a delegate?  Could someone please explain, how would I implement the above functionality using a named delegate instead (just to help with understanding it)?  TIA.  </p>