title: Button.PerformClick() across thread
body: <p>See this code:</p>
  
  <pre><code>    Imports System.Threading
  
      Private trd As Thread
  
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
      trd = New Thread(AddressOf ThreadTask)
      trd.IsBackground = True
      trd.Start()
    End Sub
  
  Sub ThreadTask()
      Thread.Sleep(50)
      Button4.PerformClick()
  End Sub
  
  Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click        
      Me.Close()
  End Sub
  </code></pre>
  
  <p>I'm trying to simulate a button click from a different thread, but the following error occurs: "An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll", at the Button4.PerformClick() line.</p>
  
  <p>How can I use this function across threads?</p>