Home All Groups Group Topic Archive Search About

Possible to monitor changes in array (with event)?

Author
25 May 2006 10:10 AM
HKSHK
Hi folks,

I hope that anyone can give me a tip about this problem.

I need to monitor the content of an array (boolean variables). The best
thing would be if I was able to create an event that's being triggered
when one of the variables changes (ideally giving the index of that
changed variable).

I thought about using a timer, but the problem is that it's not very
reliable (a variable might have changed right after it was checked), so
what can I do?

Thanks in advance for your help.

Best Regards,

HKSHK

Author
25 May 2006 11:51 AM
Phill W.
HKSHK wrote:

> I need to monitor the content of an array (boolean variables). The best
> thing would be if I was able to create an event that's being triggered
> when one of the variables changes (ideally giving the index of that
> changed variable).

Wrap your array in a class derived from CollectionBase and override its
OnSet routine to trap each change.

Class BoolArray
    Public Event ItemChanged( ByVal index as Integer, ...

    Protected Overrides OnSet( _
         ByVal Index as Integer _
       , ByVal oldValue as Object _
       , ByVal newValue as Object _
       )
       If Not [Object].Equals( oldValue, newValue ) Then
          RaiseEvent ItemSet( index, ...
       End If
    End Sub

End Class

HTH,
    Phill  W.