我正在处理多线程应用程序我在线程中传递IMAGETHREADINFO
结构nSock
显示垃圾值。这里有什么问题。IMAGETHREADINFO
的指针被声明为CServerConnectionMgr
类的成员变量。
typedef struct
{
int nScok;
CServerConnectionMgr* pConMgr;
}IMAGETHREADINFO;
void StartImageThread(SOCKET nSock)
{
stThreadInfo = new IMAGETHREADINFO;
stThreadInfo.pConMgr = this;
stThreadInfo.nScok = nSock;
m_hRecordImageThread = CreateThread ( NULL,0, (LPTHREAD_START_ROUTINE)StreamImageThread,(void*)&stThreadInfo, 0,&m_nRecordImageThreadID);
if ( NULL == m_hRecordImageThread)
{
return;
}
int CServerConnectionMgr::StreamImageThread(void *args)
{
IMAGETHREADINFO *pImageThreadInfo = (IMAGETHREADINFO*)&args;
}
pImageThreadInfo->nSock
,显示一些垃圾值pImageThreadInfo->pConMgr
正确我这显示错误的值
答案 0 :(得分:2)
(void*)&stThreadInfo
是指向stThreadInfo
指针的指针。您可能想要删除&
然后,同时更改IMAGETHREADINFO *pImageThreadInfo = (IMAGETHREADINFO*)&args;
,删除&