i went through mfc source code. it showed that when ::GetMessage()
function call in CWinThread::PumpMessage() fails, then it increments
some variable which, in the next call to PumpMessage(), which itself
is repeteadly called from CWinThread::Run(). here is the very code of
CWinThread::PumpMessage() which causes this assertion error:
if (!::GetMessage(&m_msgCur, NULL, NULL, NULL))
{
#ifdef _DEBUG
if (afxTraceFlags & traceAppMsg)
TRACE0("CWinThread::PumpMessage - Received WM_QUIT.\n");
m_nDisablePumpCount++; // application must die
// Note: prevents calling message loop things in 'ExitInstance'
// will never be decremented
#endif
return FALSE;
}
on checking documentation for ::GetMessage(), it shows that it returns
NULL when there is WM_QUIT message in the message queue.
now, line that was causing error in my case: (your case may be
different, but somehow you too are causing the application to quit,
while still working on it, like i was still trying to show a dialog
box.)
(this is part of my CAsyncSocket-derived class code)
CMySocket::OnConnect( int nErrorCode)
{
...
case WSAECONNREFUSED:
AfxMessageBox("Please check whether the server is
running.\n",MB_ICONSTOP);
AfxPostQuitMessage(0); //this caused the assertion error
break;
...
}
bye,
deepak
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm