开发者

Thread Argument Problem

开发者 https://www.devze.com 2023-02-16 12:59 出处:网络
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 mem

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

精彩评论

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