title: Invoking method with custom delegate vs. action
body: <p>I have seen Microsoft suggest using <a href="http://msdn.microsoft.com/en-us/library/ms171728%28v=vs.110%29.aspx" rel="nofollow">a custom Delegate in the InvokeRequired pattern</a></p>
  
  <p>But I can't figure out why one wouldn't just save the trouble of defining the delegate when doing something as simple as setting a control property. I'm referring to <code>Option 1</code> below which just uses the delegate <code>Action(Of String)</code> instead of a custom delegate.</p>
  
  
  
  <pre class="lang-vb prettyprint-override"><code>' Option 1
  
  Private Sub setLabelWorkingText(ByVal [text] As String)
      If Me.lblWorking.InvokeRequired Then
          Me.Invoke(New Action(Of String)(AddressOf setLabelWorkingText), [text])
      Else
          Me.lblWorking.Text = [text]
      End If
  End Sub
  
  ' Option 2
  
  Private Delegate Sub setLabelWorkingTextDelegate(ByVal [text] As String)
  
  Private Sub setLabelWorkingTextWithDel(ByVal [text] As String)
      If Me.lblWorking.InvokeRequired Then
          Me.Invoke(New setLabelWorkingTextDelegate(AddressOf setLabelWorkingTextWithDel), [text])
      Else
          Me.lblWorking.Text = [text]
      End If
  End Sub
  </code></pre>
  
  <p>I understand one difference to be that arguments can't be passed ByRef using Action and Func, but a custom delegate can specify ByRef arguments. Are there any other differences between the two?</p>