title: Using MethodInvoker without Invoke
body: <p>I am writing GUI applications for some time now and one thing I always use are MethodInvoker + lambda functions to do cross-thread access.</p>
  
  <p>From the examples I find I always see stuff like this:</p>
  
  <p><strong>Version 1</strong></p>
  
  <pre><code>if (InvokeRequired)
  {
      Invoke(new MethodInvoker(() =&gt; 
      {
          Label1.Text = "Foobar";
      });
  }
  else
  {
      Label1.Text = "Foobar";
  }
  </code></pre>
  
  <p>However this leads to code-duplication --> major baddie to me.</p>
  
  <p>So what's wrong with this?</p>
  
  <p><strong>Version 2</strong></p>
  
  <pre><code>MethodInvoker updateText = new MethodInvoker(() =&gt; 
      {
          Label1.Text = "Foobar";
      });
  
  if (InvokeRequired)
  {
      Invoke(updateText);
  }
  else
  {
      updateText();
  }
  </code></pre>
  
  <p>Now I have the functionality bundled in one variable and call it with Invoke or as a function pointer when appropriate. Is version 2 worse performance-wise? Or is i bad practice to use anonymous functions for this?</p>