Anyone find a solution to documentcompleted event?

hi,
It's a little emergency.
I have a window form project that the window form embeded a web browser object-AxSHDocVw.
When the program finish navigation the URL and show the web page in the web browser object, the program go to parse the DOM tree.
I write the parsing program into the docuemtcomplete handle. Sometime the system trigger the documentcomplete handle, but the web browser was not really download complete the whole html document.
It will cause the DOM tree parsing error.
How can I avoid this situation
And let me ensure that the navigation is really finished completely!
Thanks a lot!


Y. J.

Sample program:

Private Sub wb_DocumentComplete(ByVal sender As System.Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) Handles wb.DocumentComplete

Dim ele As IHTMLElement
Dim node As TreeNode
Doc3 = wb.Document

tvDOM.Nodes.Clear()

ele = Doc3.documentElement
node = tvDOM.Nodes.Add(ele.tagName + "_" + ele.sourceIndex.ToString)
node.Tag = ele.sourceIndex

Call add_Children(ele, node)

......... 'the parsing program

If rsPage.Read() Then
PageURL = rsPage.Item("PageURL")
PageID = rsPage.Item("PageID")
wb.Navigate(PageURL)
Doc3 = wb.Document
Else
cn.Close()
rsPage.Close()
rsPage = Nothing
cmad = Nothing
cn = Nothing
End If

End Sub

wb: AxSHDocVw.AxWebBrowser



Answer this question

Anyone find a solution to documentcompleted event?