I found that above changes makes the subscriptionlist in TwincatCom1 to be correct, but the subscriptionlist in subscriptionhandler is still populated with lots of duplicates.
Public Sub SubscribeTo(ByVal PLCAddress As String, ByVal callBack As EventHandler(Of SubscriptionHandlerEventArgs), ByVal propertyName As String)
'* Check to see if the subscription has already been created
Dim index As Integer
While index < m_SubscriptionList.Count AndAlso (m_SubscriptionList(index).CallBack <> callBack Or m_SubscriptionList(index).PropertyNameToSet <> propertyName)
index += 1
End While
'* Already subscribed and PLCAddress was changed, so unsubscribe
If (index < m_SubscriptionList.Count) AndAlso m_SubscriptionList(index).PLCAddress <> PLCAddress Then
m_CommComponent.Unsubscribe(m_SubscriptionList(index).NotificationID)
m_SubscriptionList.RemoveAt(index)
End If
'* Is there an address to subscribe to?
If (PLCAddress IsNot Nothing) AndAlso (String.Compare(PLCAddress, "") <> 0) Then
Try
If m_CommComponent IsNot Nothing Then
'* If subscription succeedded, save the subscription details
Dim temp As New SubscriptionDetail(PLCAddress, callBack)
temp.PropertyNameToSet = propertyName
If PLCAddress.ToUpper.IndexOf("NOT ") = 0 Then
temp.Invert = True
End If
m_SubscriptionList.Add(temp)
InitializeTryTimer(500)
Else
OnDisplayError("CommComponent Property not set")
End If
Catch ex As MfgControl.AdvancedHMI.Drivers.Common.PLCDriverException
'* If subscribe fails, set up for retry
InitializeSubscribeTry(ex, PLCAddress)
End Try
End If
End Sub
I don't see where this code stops duplicates except for the comment?