I assume I call the BackgroundWorker1.RunWorkerAsync() and this will treat it as Asynchronous?
"I missed something critical in the code above" Archie, you cant miss that, lol.Kidding aside, I believe the BW Progress or Completed will allow you to set text change from original UI thread without delegate and invoke
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork While Not StopThread '* Will result in cross thread operation exception Label2.Text = "Abc" '* Prevent from using excessive CPU Threading.Thread.Sleep(50) End While End Sub
Archie, not in the DoWork sub, put the text code in Progress or Completed.https://www.advancedhmi.com/forum/index.php?topic=1431.msg7591#msg7591
Private StopThread As Boolean Private StringResult As String Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork While Not StopThread Dim MyValues() As String = ModbusTCPCom1.Read("40001", 10) StringResult = MfgControl.AdvancedHMI.Drivers.Common.CalculationsAndConversions.WordsToString(MyValues) BackgroundWorker1.ReportProgress(0) '* Prevent from using excessive CPU Threading.Thread.Sleep(50) End While End Sub Private Sub MainForm_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing StopThread = True End Sub Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged Label1.Text = StringResult End Sub
When I try to download the file from reply #11, I get an "Internal Server Error" and a message to "contact the server administrator, webmaster@downloads.advancedhmi.com and inform them of the time the error occurred".