Exemple #1
0
        protected virtual void WaitForFramesToComplete(IHTMLDocument2 maindocument)
        {
            var mainHtmlDocument = (HTMLDocument)maindocument;

            var framesCount = FrameCountProcessor.GetFrameCountFromHTMLDocument(mainHtmlDocument);

            for (var i = 0; i != framesCount; ++i)
            {
                var frame = FrameByIndexProcessor.GetFrameFromHTMLDocument(i, mainHtmlDocument);

                if (frame == null)
                {
                    continue;
                }

                IHTMLDocument2 document;

                try
                {
                    WaitWhileIEBusy(frame);
                    WaitWhileIEReadyStateNotComplete(frame);
                    WaitWhileFrameDocumentNotAvailable(frame);

                    document = (IHTMLDocument2)frame.Document;
                }
                finally
                {
                    // free frame
                    Marshal.ReleaseComObject(frame);
                }

                WaitWhileDocumentStateNotComplete(document);
                WaitForFramesToComplete(document);
            }
        }
Exemple #2
0
        public virtual void WaitForFramesToComplete(IHTMLDocument2 maindocument)
        {
            var mainHtmlDocument = UtilityClass.GetWithFailOver(() => (HTMLDocument)maindocument);

            var framesCount = FrameCountProcessor.GetFrameCountFromHTMLDocument(mainHtmlDocument);

            for (var i = 0; i != framesCount; ++i)
            {
                var frame = FrameByIndexProcessor.GetFrameFromHTMLDocument(i, mainHtmlDocument);

                if (frame == null)
                {
                    continue;
                }

                IHTMLDocument2 frameDocument;
                try
                {
                    if (!WaitWhileIEBusy(frame))
                    {
                        continue;
                    }

                    if (!WaitWhileIEReadyStateNotComplete(frame))
                    {
                        continue;
                    }

                    WaitWhileFrameDocumentNotAvailable(frame);

                    frameDocument = (IHTMLDocument2)frame.Document;
                }
                finally
                {
                    // free frame
                    Marshal.ReleaseComObject(frame);
                }

                WaitWhileDocumentStateNotCompleteOrInteractive(frameDocument);
                WaitForFramesToComplete(frameDocument);
            }
        }