ConductWith Causing a memory leak

Topics: Actions & Coroutines, Bugs
Jul 24, 2012 at 6:55 AM

 public static void ActivateWith(this IActivate child, IActivate parent) {
            EventHandler<ActivationEventArgs> handler = (s, e) => child.Activate();
            parent.Activated += handler;

            var deactivator = parent as IDeactivate;
            if(deactivator != null) {
                EventHandler<DeactivationEventArgs> handler2 = null;
                handler2 = (s, e) => {
                    if (e.WasClosed) {
                        parent.Activated -= handler;
                        deactivator.Deactivated -= handler2;
                    }
                };
                deactivator.Deactivated += handler2;
            }
        }

always add handler to Delegation chain. 

 private void LoadPagePluginBar()
        {
            
            List<IPagePluginBar> pluginBars =
                this.ProtocolFacedeMgr.CreatePagePluginBar(uri);
            foreach (IPagePluginBar pagePluginBar in pluginBars)
            {
              

 		   pagePluginBar.TabId = Id;
                    var s = (pagePluginBar as Screen);
                    if (s != null)
                    {
                    
                        s.ConductWith(this);
                    }
                    this.PluginBarsOnPage.Add(pagePluginBar);

            }
            this.ShowPluginBar = this.PluginBarsOnPage.Count != 0;
          }
if clear PluginBarsOnPage collection,re-excute LoadPagePluginBar,last time created screen Still fire OnActivate method.

Aug 15, 2012 at 1:13 PM

May you create an issue for that and attach a complete sample.