Hmya, you're struggling but it's a Good Thing. To get your code to compile, recode the BeginInvoke() method like this:
Me.BeginInvoke(New System.EventHandler(AddressOf UpdateUI), EventArgs.Empty)
I'm using "Me" instead of "statusLabel". Both work, both are Windows Forms object that were created on another thread. Using the form instance instead of the control instance make (just a bit) more sense.
You are already using MethodInvoker. But then switch to EventHandler without passing anything useful. To stay consistent, you could do it like this instead:
Dim mi As MethodInvoker = New MethodInvoker(AddressOf FillMyData)
mi.BeginInvoke(Nothing, Nothing)
...
Private Sub FillMyData()
'... Do your stuff
Me.BeginInvoke(New MethodInvoker(AddressOf UpdateUI))
End Sub
Private Sub UpdateUI()
'... etc
End Sub
All of this ugliness would easily be avoided if you used the BackgroundWorker class. Instead of handing the code on a plate, I'll let you figure it out by yourself. Good Thing and all that. Yell when you've thought about it for a while and got stuck.
Me.BeginInvoke(New System.EventHandler(AddressOf UpdateUI), EventArgs.Empty)
I'm using "Me" instead of "statusLabel". Both work, both are Windows Forms object that were created on another thread. Using the form instance instead of the control instance make (just a bit) more sense.
You are already using MethodInvoker. But then switch to EventHandler without passing anything useful. To stay consistent, you could do it like this instead:
Dim mi As MethodInvoker = New MethodInvoker(AddressOf FillMyData)
mi.BeginInvoke(Nothing, Nothing)
...
Private Sub FillMyData()
'... Do your stuff
Me.BeginInvoke(New MethodInvoker(AddressOf UpdateUI))
End Sub
Private Sub UpdateUI()
'... etc
End Sub
All of this ugliness would easily be avoided if you used the BackgroundWorker class. Instead of handing the code on a plate, I'll let you figure it out by yourself. Good Thing and all that. Yell when you've thought about it for a while and got stuck.