Circular Reference Between Modules when 2 Class Modules Listen to Each others Events 
Author Message
 Circular Reference Between Modules when 2 Class Modules Listen to Each others Events

I created two collection classes that I want to keep synchronized. When an
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
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?



Wed, 02 Jun 2004 06:24:29 GMT  
 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?

>.



Wed, 02 Jun 2004 08:44:30 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Circular Reference Between Modules when 2 Class Modules Listen to Each others Events

2. Class modules 97 - Refering to array within a custom class module

3. Accessing procedures of a class module from another class module

4. Class Module and Module

5. Class Modules & Modules

6. VB Modules/Class Modules

7. class module vs. module

8. modules and class modules

9. Returning the name of a module/class module

10. Modules or Class modules?

11. Q(VB5) : Different between module & class module

12. Q: Code Module vs UserControl (Form, Class) module.

 

 
Powered by phpBB® Forum Software