开发者

Thread Argument Problem

I have working on multithreaded application I am passing IMAGETHREADINFO structure in thread here nSock is showing garbage value. What is the problem here.pointer to IMAGETHREADINFO is declared as member variable of CServerConnectionMgr class.

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);                                                                                                 开发者_StackOverflow                                            
if ( NULL == m_hRecordImageThread)
{
   return;
} 
int CServerConnectionMgr::StreamImageThread(void *args)
{   

    IMAGETHREADINFO *pImageThreadInfo = (IMAGETHREADINFO*)&args;

}
  1. This is variable pImageThreadInfo->nSock showing some garbage value
  2. This pImageThreadInfo->pConMgr is coming correctly

I this is showing wrong value


(void*)&stThreadInfo is a pointer to the stThreadInfo pointer. You likely want to remove the &

And then, also change IMAGETHREADINFO *pImageThreadInfo = (IMAGETHREADINFO*)&args;, remove the &

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜