title: Delegates in Threads and Anonymous methods - Update controls in new Thread
body: <p>I was using multithreading in my window form. Following is my class. 
  I have a label control in my designer and under the newly created thread I am updating it's text property.</p>
  
  <p>Following is the case when I encapsulated the function "UpdateLabel" in a delegate "Del".
  and it works fine.</p>
  
  <pre><code>public partial class DynamicType : Form
      {
          delegate void Del(String x);
  
          public DynamicType()
          {
              InitializeComponent();
          }
  
          private void DynamicType_Load(object sender, EventArgs e)
          {
              System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(StartThread));
              t.Start();
          }
  
          private void StartThread()
          {
              this.Invoke(new Del(UpdateLabel), new object[] { "Hi" });
          }
  
          private void UpdateLabel(String str)
          {
              label1.Text = str;
          }
      }
  </code></pre>
  
  <p>I have a another case called Anonymous Methods. Upon implementing the Anonymous methods
  in the following methods. Following are the definitions.</p>
  
  <pre><code>private void StartThread()
          {
              UpdateLabel("Hi");
          }
  
  
  
  private void UpdateLabel(String str)
          {
              Del Label = delegate(String k)
               {
                   label1.Text = k;
  
               };
              Label("hi");
          }
  </code></pre>
  
  <p>Cross-thread operation not valid: Control 'label1' accessed from a thread other than the thread it was created on.</p>
  
  <p>My query is in the previous case I was using the delegates and it worked fine and in case of anonymous methods I removed the extra functions by directly instantiating the delegates and tried to update the label control text property and it gave the crash as mentioned above. Reason?</p>