Hi All,

I have a BackgroundWorker and using a delegate to update an UI on a different thread. Everything is working except the "lblInfo.Left = (Me.Width / 3) - (lblInfo.Width / 4)".
I need this line since it allows me to center the text on the UI as I have several Subroutines and they all have various lengths in text. If possible, Can someone help me
pass the lblInfo.Left = (Me.Width / 3) - (lblInfo.Width / 4) from the delegate so I don't get a IllegalCrossThread. ANY help will be greatly appreciated.

Thanks in Advance.



Delegate Sub SetLabelTextInvoker(ByVal lblInfo As Label, ByVal Text As String)

Sub SetLabelText(ByVal lblInfo As Label, ByVal Text As String)
If lblInfo.InvokeRequired = True Then
lblInfo.Invoke(New SetLabelTextInvoker(AddressOf SetLabelText), lblInfo, Text)
Else
lblInfo.Text = Text
End If
End Sub


Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

lblInfo.Left = (Me.Width / 3) - (lblInfo.Width / 4) ' line that done work unless I set the Control.CheckForIllegalCrossThreadCalls = False which I don't want to.
SetLabelText(lblInfo, "File is being copied and will take a while. Please Wait...")
BackgroundWorker1.ReportProgress(20)

Copy_5GB_Image()

lblInfo.Left = (Me.Width / 3) - (lblInfo.Width / 4)
SetLabelText(lblInfo, "Image Copied Successfully.")

End Sub