I have a function that is executed. This has some events that fire some Subs.
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.
Is this possible?
UPDATE
code sample, this code is executed on the main thread
Dim url As String = Ftp
If Not url.StartsWith("ftp://") Then url = "ftp://" & 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) & "\"
Dim localFilenameUpload = Path.GetFileName(Datei)
Dim remoteDirectory = uri.AbsolutePath
Dim remoteFilename = Path.GetFileName(Datei)
ftpUpload.UploadAsync(localDirectory, localFilenameUpload, remoteDirectory, remoteFilename)
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.
Private Sub Upload_UploadFileCompleted(ByVal sender As Object, ByVal e As UploadFileCompletedEventLibArgs) Handles ftpUpload.UploadFileCompleted
'dothiings with the interface
End Sub