Hi Doug,
"Doug Taylor" <do*********@accipitersoftware.com> wrote in message
news:e1**************************@posting.google.c om...
Shaun,
While there is certainly nothing wrong with this approach, you will
now have a circular reference. The MDIParent object has a reference
to the MDIChild object and the MDIChild object has a reference to the
parent. You have to be Very careful with circular references.
Another approach would be to put an event in the MDIChild class. In
the MDIParent class write an event handler that calls or does your
drawing task. Then in the child you simply raise the event whenever
you want the drawing to happen.
This is just another approach FYI.
A few things:
1. What I suggested to Shaun will not create a circular reference
situation. In the code snippet, the MainWindow variable is declared local to
the routine. Once the routine exits, the variable goes out of scope and the
reference is no more.
2. If Shaun *were* to create a circular reference situation (say he
assigns a reference to the MainWindow instance to a *member* variable of the
child window instance) this would still be no big deal. The garbage
collector implementation in .NET will still reclaim both instances when they
are no longer "reachable" by the application.
3. Subscribing to an event creates a reference from the event source
object to the event subscriber object. Thus your suggestion would, in fact,
create a circular reference situation. Fortunately this is no big deal (see
#2).
Regards,
Dan