title: Run Sub with handle on main thread
body: <p>I have a function that is executed. This has some events that fire some Subs.</p>
  
  <p>The function runs on a different thread then the main thread. Problem I have with this is that the subs connected with the event are also called on a different thread. I would need these to be called on the main thread so I can access the interface.</p>
  
  <p>Is this possible?</p>
  
  <p>UPDATE</p>
  
  <p>code sample, this code is executed on the main thread</p>
  
  <pre><code> Dim url As String = Ftp
  
  
  If Not url.StartsWith("ftp://") Then url = "ftp://" &amp; url
  
  Dim uri As New Uri(url)
  
  ftpUpload.Host = uri.Host
  ftpUpload.UserName = Benutzername
  ftpUpload.Password = Passwort
  ftpUpload.Port = 21
  Dim localDirectory = Path.GetDirectoryName(Datei) &amp; "\"
  Dim localFilenameUpload = Path.GetFileName(Datei)
  Dim remoteDirectory = uri.AbsolutePath
  Dim remoteFilename = Path.GetFileName(Datei)
  ftpUpload.UploadAsync(localDirectory, localFilenameUpload, remoteDirectory, remoteFilename)
  </code></pre>
  
  <p>the very last line calls a function, this is executed on a different thread and has some events. these events fire following sub on the different thread, I would need them on the main thread.</p>
  
  <pre><code>Private Sub Upload_UploadFileCompleted(ByVal sender As Object, ByVal e As UploadFileCompletedEventLibArgs) Handles ftpUpload.UploadFileCompleted
  
  'dothiings with the interface
  
  End Sub
  </code></pre>