I am using IGraphicsContainerEvents_ElementAddedEventHandler to do stuff with graphics added by users in an ArcMap session using the standard drawing toolbar. As the code snippet below shows, its a pretty straight-forward process, and works perfect for the first few (2-3) graphics added. However, eventually 'ElementAdded' stops firing for no apparent reason (i.e no errors that I can catch).
Does anyone have any idea of what would be unregistering the listener (OnElementAdded) and/or preventing the ElementAdded event to be fired?
ICompositeGraphicsLayer activeGraphicsLayer = (ICompositeGraphicsLayer)mxDoc.ActiveView.FocusMap.ActiveGraphicsLayer;
IGraphicsContainerEvents_Event containerEvents = (IGraphicsContainerEvents_Event)activeGraphicsLayer;
containerEvents.ElementAdded += new IGraphicsContainerEvents_ElementAddedEventHandler(OnElementAdded);
private void OnElementAdded(IElement Element)
{
// do stuff
}