GraphicsContainer and Timer - using Addins

Discussion created by rockzZ25 on Sep 14, 2011
Latest reply on Sep 15, 2011 by rockzZ25
I have some code that runs fine and retrieves all elements in the active view:

Basically the user adds a custom print template (.mxd) in using a button on the addin. In 9.3 version the above problem did not occur but in version 10, when the user selects the new custom template, the problem occurs.

            IMxDocument pMxDocument;
            IMap pMap;
            IPageLayout pLayout;
            IActiveView pActiveView;
            IGraphicsContainer pGC;


            pActiveView=pMap as IActiveView;

            pGC=pMxDocument.ActiveView as IGraphicsContainer;

            bool populated=false;
            IElement pElem;

where pElem is returned as not null because the active view has text elements.

However this code is ran again automatically based upon a timer that fires the event every 30 seconds.

The issue is that the in above code on the second run, pGC.Next() seems to always return a null hence it is unable to detect any of the elements in the activeView. Although the elements are still present in the view.
Anybody experienced something similar or know of any thing that might be causing this behavior.



Some information i found but not sure if it is relevant.

When working with the IActiveView interface on a MapDocument object, you should always first call IActiveView::Activate() in order to properly initialize the display of the PageLayout or Map object.  If your application has a user interface, you should call Activate() with the hWnd of the application's client area.

I tried the code


however that doesnt change anything.