
Circular Reference Between Modules when 2 Class Modules Listen to Each others Events
Sure. First, if you do not understand what a circular
reference is:
Class A changes so it copies the Change to B. This causes
B to change which in turn copies it's change to A. So A
realizes that it has been changes and copies its change to
B. This goes on until the end of the world
(theoretically) or until you run out of stack space, or
until some smart program realizes you've created a loop
(which is what happened.)
One fix would be to add to each class a boolean property,
MirrorDisabled which would normally be false. Now, when a
change occurs in A set the property MirrorDisabled in
class B to true. In class B where you are detecting the
change put something like:
Sub MirrorChange()
If Me.MirrorDisabled Then
Exit Sub
End If
' other stuff
End Sub
Then after you've made your changes turn MirrorDisabled
back to false. Do the same thing now to Class A that you
did to B.
- Tim
Quote:
>-----Original Message-----
>I created two collection classes that I want to keep
synchronized. When an
Quote:
>item is added to one collection class, an event is raised
so the other
>collection adds the same item . The problem is that
declaring module level
Quote:
>variables in each collection class to listen for events
in the mirror
>collection class produces the error "Circular References
Between Modules."
>Can someone please help?
>.