这是我的一个线程
UINT ListenThread(void *p)
{
   
    //准备接受请求

while(1)
{
if(!pDlg->bAppend)
{
// AfxEndThread(0);
return 0;
}
CString strError;
int error;
ASSERT(pDlg!=NULL);

SOCKET s=accept(pDlg->m_hSocket,NULL,NULL);
if(s==SOCKET_ERROR)
{
if(pDlg->bAppend)
{
 strError.Format("Accept Error:%d ",error=WSAGetLastError());
 AfxMessageBox(strError);
 closesocket(pDlg->m_hSocket);
 return -1;
}
else
{
break;
}
}
AfxMessageBox("客户机已连接上");
CFile file;
while(1)
{
CJSDDlg dlg;
dlg.savesend();///////////////////////////////////////////////
char *sendBuf="你好!";
char *message="尚未开始演示!";
//send(s,sendBuf,strlen(sendBuf)+1,0);
if(!file.Open("Temp.bmp", CFile::modeRead | CFile::typeBinary))
{
send(s,message,strlen(message)+1,0);
}
else
{
send(s,sendBuf,strlen(sendBuf)+1,0);
}
}
}
return 0;
}
里边如果没有dlg.savesend()这句程序就会正常运行,而加了这句程序执行到这里就会出现异常,dlg.savesend()是没有问题的,这句在其他地方调用就不会出错,只有在这调用时会出现异常,为什么?怎么解决?