Re: Maintain list of attached event handlers (.Net 1.1)



"Armin Zingler" <az.nospam@xxxxxxxxxx> wrote in message news:eEhlPQzwHHA.3364@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

here's the short version:
How can I remember which event handlers did I attach to which events?

Background:
- I have an object tree. There is one root object, containing sub objects,
containing sub objects, and so on. All the objects in the tree can raise
events.

- In a Form's Load event, I recursively process the object tree and attach
event handlers to all the events of the objects in the tree.

- Whenever an event fires, I detach the event handler. (because it won't fire twice)

Why detach the handler right away? Why not wait until the form closes, then detach them all? Follow the same (visitor) pattern you followed to attach the handlers to detach them.
--
John Saunders [MVP]

.



Relevant Pages

  • Re: Store added event handlers
    ... list of sub objects, that can contain sub objects, and so on. ... I recursively process the object tree and attach ... event handlers to all the events of the objects in the tree. ... I detach the handler from the objects' events. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Maintain list of attached event handlers (.Net 1.1)
    ... > - In a Form's Load event, I recursively process the object tree ... > event handlers to all the events of the objects in the tree. ... > I must detach the remaining event handlers when closing the Form. ... event fires, other than a very minimal amount of memory occupied. ...
    (microsoft.public.dotnet.framework)
  • Re: Maintain list of attached event handlers (.Net 1.1)
    ... - In a Form's Load event, I recursively process the object tree and attach ... event handlers to all the events of the objects in the tree. ... I must detach the remaining event handlers when closing the Form. ... It is not really hurting anything for it to remain attached even after the event fires, other than a very minimal amount of memory occupied. ...
    (microsoft.public.dotnet.framework)
  • Maintain list of attached event handlers (.Net 1.1)
    ... How can I remember which event handlers did I attach to which events? ... I recursively process the object tree and attach ... I must detach the remaining event handlers when closing the Form. ...
    (microsoft.public.dotnet.framework)
  • Re: Debug document lib event
    ... It seems you can't attach ... to the ASP.NET worker process to debug those event handlers. ... I've used some MessageBoxes to display some debug information. ...
    (microsoft.public.sharepoint.portalserver.development)

Loading