15
« on: September 23, 2013, 11:40:37 AM »
I'm getting the following error: "Invoke or BeginInvoke cannot be called on a control until the window handle has been created."at line 612 of ModbusTcpComm and I haven't been able to get rid of it. I am trying to monitor the PLC using a "backgroundworker" component on a form that I want to keep minimized most of the time. However, that form should show a progressbar to indicate that the program is running. There may be a better approach for what I am trying to do, I'm open.
Regardless, I would like to know what I did wrong.
I got rid of unnecessary parts, and now I have just one form, with a ModbusTcpComm component (PLC), and a Background worker on it.
' I added the following code at the bottom of MainForm.vb. Notice that this contains an "End Class", which replaces the one that's there.
Dim asd As New secondclass
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
MsgBox(asd.readPLC(40100))
End Sub
End Class
Public Class secondclass
Public Function readPLC(ByVal address As UInteger)
Return MainForm.PLC.Read(address)
End Function
End Class
Any help would be much appreciated!
Thanks,
Quinton Wideman
Rolan Inc