Can I set timeout in IWebBrowser2 Navigate?
-
Due to poor network connection, sometimes the page does not fully load when I call Navigate. My code performs certain task after the entire page has done loading. Does anyone know if there is a default timeout for Navigate? If not, is there an elegant way to wait for a while before I call Navigate again? I could create a thread to monitor if my OnDocumentComplete function has been called but I am hoping for another way.
-
Due to poor network connection, sometimes the page does not fully load when I call Navigate. My code performs certain task after the entire page has done loading. Does anyone know if there is a default timeout for Navigate? If not, is there an elegant way to wait for a while before I call Navigate again? I could create a thread to monitor if my OnDocumentComplete function has been called but I am hoping for another way.
I am answering my own post but I don't think starting a thread and checking to see whether the page has done loading periodically will work because the Navigate call is single-threaded.
-
I am answering my own post but I don't think starting a thread and checking to see whether the page has done loading periodically will work because the Navigate call is single-threaded.
Try this
BOOL m_bReady = 0;
BSTR bsStatus;
CString str;m_pBrowser->Navigate2(vaURL,null,null,null,null) ;
while(!m_bReady)
{
m_pBrowser->get_StatusText(&bsStatus);
mStr = bsStatus;
if(mStr == "Done") m_bReady=1;
} -
Try this
BOOL m_bReady = 0;
BSTR bsStatus;
CString str;m_pBrowser->Navigate2(vaURL,null,null,null,null) ;
while(!m_bReady)
{
m_pBrowser->get_StatusText(&bsStatus);
mStr = bsStatus;
if(mStr == "Done") m_bReady=1;
}Thanks for the reply. But as I was trying to say with my second post, the browser functions are single-threaded so the while-loop will go into an infinite loop since Navigate2 won't get a chance to run. As far as I know, the only way to check if the page has finished loading or not is to write a call-back function.