12
« on: January 26, 2025, 05:09:56 PM »
That's interesting, I never seen it done that way. I tested it and it does work.
If you are using a DataSubscriber2, the callback routine should be synchronizing to the UI thread and not allow parallel execution of the callback routine. I would be interested in seeing a breakpoint put in the DataSubscriber2 code in the OnDataReturned routine to see if the m_SynchronizationContext is set to anything:
Protected Overridable Sub OnDataReturned(ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
If m_synchronizationContext IsNot Nothing Then
m_synchronizationContext.Post(AddressOf DataReturnedSync, e)
Else
RaiseEvent DataReturned(Me, e)
End If
End Sub
'****************************************************************************
'* This is required to sync the event back to the parent form's main thread
'****************************************************************************
'Dim drsd As EventHandler(Of MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs) = AddressOf DataReturnedSync
Private Sub DataReturnedSync(ByVal e As Object)
RaiseEvent DataReturned(Me, DirectCast(e, MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs))
End Sub