title: Adding a Label to a form from a thread
body: <p>I am working on a VB.Net project and I'm trying to add a label to my form from a thread that is running in the background (a necessary evil).</p>
  
  <p>I have created the Global variable SmallTextLabel (Type: Label) and have assigned all of the properties I want to it.  I am now just trying to add it to my form using Me.Controls.Add(SmallTextLabel).  Every time I run this code it tells me that i must invoke the control.  I scream at the screen that that's what I'm trying to do, but does it listen?!</p>
  
  <p>Anyway, I have scoured the internet for the past 4 hours and have not managed to resolve this, so please... can anyone out there shine some light on this for me?</p>
  
  <p>This is the code that I'm currently calling with AddSmallLabelControl(SmallTextLabel)</p>
  
  <p><strong>Amended example</strong></p>
  
  <pre><code>Private Delegate Sub AddSmallLabelControlHandler(ByVal test As Label)
  Private Sub AddSmallLabelControl(ByVal test As Label)
      If Me.InvokeRequired Then
          Dim d As New AddSmallLabelControlHandler(AddressOf AddSmallLabelControl)
          Me.Invoke(d, test)
      Else
          Me.Controls.Add(test)
          test.BringToFront()
      End If
  End Sub
  
  Private Sub ShowScanConfirmationLabel()
      Dim SmallTextLabel As New Label
      Dim TahomaSmall As New Font("Tahoma", 20, FontStyle.Bold)
  
      With SmallTextLabel
          .Height = 40
          .Width = 312
          .Location = New Point(3, 121)
          .BackColor = Color.Green
          .Text = "Testing"
          .TextAlign = ContentAlignment.TopCenter
          .Font = TahomaSmall
      End With
  
      End With
      Call AddSmallLabelControl(SmallTextLabel)
  End Sub
  
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      Dim MakeLabelsVisibleHandler As New ThreadStart(AddressOf MakeLabelsVisible)
      Dim timerThread As New Thread(MakeLabelsVisibleHandler)
      timerThread.Start()
  End Sub
  
  Private Sub MakeLabelsVisible()
      ShowScanConfirmationLabel()
  End Sub
  </code></pre>