Hi all,
I'm using WTL and COM, I tried to implement refreshing my webpage after reconnect to the internet. I have a thread monitering the net status who will call SendMessage to notify main thread to reload the webpage using Navigate2.
Unfortunately,I ran into an odd occurrence.After the main thread receive the notification and call navigate,I found documentcomplete event not fired.But after replacing SendMessage with PostMessage, everything works fine.why would this happen?
void CFrmWeb::OnNetStateChanged(bool good)
{
if(good && !m_bIsNetAvailable)
{
if(::IsWindow(m_peerEntity.m_hWnd))
{
::SendMessage(GetHandle(),WM_NETWORK_RECOVERY,0,0);
}
}
m_bIsNetAvailable = good;
}
BOOL CFrmWeb::Fx_ProcessWindowMessage(CSHSignalArgs &e)
{
UINT msg = e.m_msg.message;
if(msg == WM_NETWORK_RECOVERY)
{
ShowPage(m_strUrl);
}
return __super::Fx_ProcessWindowMessage(e);
}
ShowPage is a wrapper for Navigate2 of WebBrowser2,Fx_ProcessWindowMessage is the message handler.I have confirmed that the WM_NETWORK_RECOVERY is received and showpage is called in main thread,but I just can't get documentcomplete fired. But when using PostMessage, everything works fine!
Please help me out, any explanation would be appreciated!