kadarb
January 2nd, 2003, 11:48 AM
I have an application which runs the following routines.
1. RunThreads
Is activated whenever start button is pressed.
It activates 3 threads. One of them is "TCPIPThreadFunc".
Once in a while I have protection error in the second
line of "TCPIPThreadFunc" thread because "pTheApp->m_pMainWnd"
is garbaged.
Is it possible that the thread is activated before
pTheApp->m_pThreadTCPIP gets it's value ??? If not what is the
problem?!?!?!
Thanks
BOOL RunThreads()
{
//run TCPIP thread /*********** T C P I P *****************/
CDynTCPIPApp * pTheApp = ( CDynTCPIPApp * )AfxGetApp();
pTheApp->m_pThreadTCPIP = AfxBeginThread( TCPIPThreadFunc, 0 );
if( !pTheApp->m_pThreadTCPIP )
{
MessageBox( NULL, "TCP IP Thread can't be created",
"Thread Info", MB_OK|MB_ICONSTOP );
return FAILURE;
}
.
.
.
.
.
.
}
UINT TCPIPThreadFunc( LPVOID pParam )
{
CDynTCPIPApp * pTheApp = ( CDynTCPIPApp * )AfxGetApp();
pTheApp->m_pThreadTCPIP->m_pMainWnd = pTheApp->m_pMainWnd;
.
.
.
.
.
}
1. RunThreads
Is activated whenever start button is pressed.
It activates 3 threads. One of them is "TCPIPThreadFunc".
Once in a while I have protection error in the second
line of "TCPIPThreadFunc" thread because "pTheApp->m_pMainWnd"
is garbaged.
Is it possible that the thread is activated before
pTheApp->m_pThreadTCPIP gets it's value ??? If not what is the
problem?!?!?!
Thanks
BOOL RunThreads()
{
//run TCPIP thread /*********** T C P I P *****************/
CDynTCPIPApp * pTheApp = ( CDynTCPIPApp * )AfxGetApp();
pTheApp->m_pThreadTCPIP = AfxBeginThread( TCPIPThreadFunc, 0 );
if( !pTheApp->m_pThreadTCPIP )
{
MessageBox( NULL, "TCP IP Thread can't be created",
"Thread Info", MB_OK|MB_ICONSTOP );
return FAILURE;
}
.
.
.
.
.
.
}
UINT TCPIPThreadFunc( LPVOID pParam )
{
CDynTCPIPApp * pTheApp = ( CDynTCPIPApp * )AfxGetApp();
pTheApp->m_pThreadTCPIP->m_pMainWnd = pTheApp->m_pMainWnd;
.
.
.
.
.
}