Update label from mainform class with backgroundworker from another class
I have two classes. Public Class MainForm Private Project As clsProject Private Sub btnDo_Click ... Backgroundworker.RunWorkerAsync() End Sub Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork Project = New clsProject End Sub and two methods inside MainForm Public Shared Sub setLabelTxt(ByVal text As String, ByVal lbl As Label) If lbl.InvokeRequired Then lbl.Invoke(New setLabelTxtInvoker(AddressOf setLabelTxt), text, lbl) Else lbl.Text = text End If End Sub Public Delegate Sub setLabelTxtInvoker