title: Control.BeginInvoke not working with TextBox.AppendText, Cross Threading
body: <p>I want to expose a method to update a text box with messages as a status log. I would like to use the AppendText method but I'm experiencing a strange multi threading issue when using it. I'm able to append new messages by concatenation just fine. The issue presents it's self as the text box not being shown, and then the Cross Thread access error shows up when closing the form. Here are examples of what works and what does not:</p>
  
  <p>Working but not like AppendText unless extra steps are taken which is the last resort: </p>
  
  <pre><code>Public Sub AddMessage2(ByVal newMessage As String)
      If TextBoxStatus.InvokeRequired Then
          TextBoxStatus.BeginInvoke(Sub() TextBoxStatus.Text = TextBoxStatus.Text &amp; newMessage &amp; ControlChars.CrLf)
      Else
          TextBoxStatus.Text = TextBoxStatus.Text &amp; newMessage &amp; ControlChars.CrLf
      End If
  End Sub
  </code></pre>
  
  <p>What I would like to use but does not work:</p>
  
  <pre><code>Public Sub AddMessage(ByVal newMessage As String)
      If TextBoxStatus.InvokeRequired Then
          TextBoxStatus.BeginInvoke(Sub() TextBoxStatus.AppendText(newMessage))
      Else
          TextBoxStatus.AppendText(newMessage)
      End If
  End Sub
  </code></pre>
  
  <p>Additional info and updates:
  First of all I apologize for likely not supplying enough info up front.</p>
  
  <p>At least part of the issue seems to be instantiating the form and calling <code>AddMessage(newMessage)</code> before calling <code>Show()</code> because the following code works:</p>
  
  <pre><code>Public Sub AddMessage(ByVal newMessage As String)
      If Me.Created Then
          If TextBoxStatus.InvokeRequired Then
              TextBoxStatus.BeginInvoke(Sub() TextBoxStatus.AppendText(newMessage))
          Else
              TextBoxStatus.AppendText(newMessage)
          End If
      End If
  End Sub
  </code></pre>
  
  <p>I can always do something like the following, but I would like to what's going on :)</p>
  
  <pre><code>Private backLog As String = ""
  Public Sub AddMessage(ByVal newMessage As String)
      If Me.Created Then
          If TextBoxStatus.InvokeRequired Then
              TextBoxStatus.BeginInvoke(Sub() TextBoxStatus.AppendText(backLog &amp; newMessage))
          Else
              TextBoxStatus.AppendText(backLog &amp; newMessage)
          End If
          backLog = ""
      Else
          backLog &amp;= newMessage
      End If
  End Sub
  </code></pre>
  
  <p>Also I don't consider this to be very elegant... especially when I add log size limits</p>