2011-03-10 65 views
1

我有多線程應用程序的工作我正在通過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; 

} 
  1. 這是可變pImageThreadInfo->nSock表示一些垃圾值
  2. pImageThreadInfo->pConMgr即將正確

我這表示錯誤的值

回答

2

(void*)&stThreadInfo是一個指向stThreadInfo指針。你可能想要刪除&

然後,也改變IMAGETHREADINFO *pImageThreadInfo = (IMAGETHREADINFO*)&args;,除去&

+0

抱歉它是爲我工作的罰款now.Thanks埃裏克 – 2011-03-10 12:57:27