It didn't work.
Here is what kind of works, if I don't make any changes to the property and leave it as is:
'**************************************************************
'* Stop the polling of subscribed data
'**************************************************************
Private m_DisableSubscriptions As Boolean
Public Property DisableSubscriptions() As Boolean Implements IComComponent.DisableSubscriptions
Get
Return m_DisableSubscriptions
End Get
Set(ByVal value As Boolean)
If m_DisableSubscriptions <> value Then
m_DisableSubscriptions = value
End If
End Set
End Property
and then just add If condition at the end of DataChangedCallBack:
Private Sub DataChangedCallBack(ByVal clientHandle As Object, ByVal requestHandle As Object, ByVal values() As Opc.Da.ItemValueResult)
For i = 0 To values.Length - 1
Dim ReturnedValues() As String = {Convert.ToString(values(i).Value)}
Dim PolledAddress As PolledAddressInfo = DirectCast(values(i).ClientHandle, PolledAddressInfo)
'For j = 0 To Subscription.Items.Count - 1
'If PolledAddress.OPCItem.ItemName = DirectCast(Subscription.Items(j).ClientHandle, PolledAddressInfo).OPCItem.ItemName Then
Dim PLCAddress As String = values(i).ItemName
'* If there is a Topic, strip it back off before sending back to subscriber
If m_OPCTopic IsNot Nothing AndAlso Not String.IsNullOrEmpty(m_OPCTopic) Then
PLCAddress = PLCAddress.Substring(m_OPCTopic.Length + 2)
End If
If Not Me.m_DisableSubscriptions Then
Dim x As New MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs(ReturnedValues, PLCAddress, 0)
x.SubscriptionID = PolledAddress.ID
Dim z() As Object = {Me, x}
m_SynchronizingObject.BeginInvoke(PolledAddress.dlgCallBack, z)
End If
'End If
'Next
Next
End Sub
Now, if I disable subscriptions then the control is showing the last value it received and is not getting updated value (even though I still keep on changing that value with another control).
The only issue is that when I enable subscriptions again, if the value is different from what the control received last, it doesn't get shown and will be updated only with the next change of that value.
So, I guess that when enabling subscriptions all the subscribed values would have to be re-read somehow.