AdvancedHMI Software
General Category => Support Questions => Topic started by: WellsCPak on June 22, 2015, 10:35:24 AM
-
I've been seeing this error thrown from the comm driver on a hidden form for a few revisions of AHMI, I patched it by checking that the window handle is created before establishing a connection with the driver. It seems to work well so far, but if you have a better way to handle this error, please let me know. =]
-
Do you have an event handler for the ConnectionEstablished event?
-
No. Should I?
-
No. I was just trying to see if I can replicate the problem.
-
Try this code and see how it works:
Protected Overridable Sub OnConnectionEstablished(ByVal e As EventArgs)
If m_SynchronizingObject IsNot Nothing AndAlso m_SynchronizingObject.InvokeRequired Then
Dim Parameters() As Object = {Me, EventArgs.Empty}
If m_SynchronizingObject IsNot Nothing Then
If TypeOf (m_SynchronizingObject) Is System.Windows.Forms.Control AndAlso DirectCast(m_SynchronizingObject, System.Windows.Forms.Control).IsHandleCreated Then
m_SynchronizingObject.BeginInvoke(oced, Parameters)
End If
End If
Else
RaiseEvent ConnectionEstablished(Me, e)
End If
End Sub