/// <summary>
        /// Attach the event repeater to the specified document instance. Call Detach
        /// when you no longer want to receive events from the document.
        /// </summary>
        /// <param name="webBrowser"></param>
        public void Attach(IHTMLDocument2 document)
        {
            // confirm pre-conditions
            Debug.Assert(document != null);
            Debug.Assert(connectionPoint == null);

            // query for the IConnectionPointContainer interface
            IConnectionPointContainer cpContainer = (IConnectionPointContainer)document;

            // find the HTMLDocumentEvents2 connection point
            cpContainer.FindConnectionPoint(ref iidHTMLDocumentEvents2, out connectionPoint);

            // attach to the event interface
            connectionPoint.Advise(this, out connectionPointCookie);

            //cache a handle to the document
            HtmlDocument = document;

            _eventCounter.Reset();
        }