Technokrat
Programmer
hello,
I'm trying to use a thread to retrieve inventory level information from a db, and store it in a map. Below I have included the struct from the header file, and the call to the thread. I am initializing the structure with an inventory item id, and date range prior to the thread call. However, once inside the thread the information pointed to in the structure is no longer available. Can anybody see what I'm doing wrong, or does anybody have a different recommended approach?
pInvDetail->csInvID no longer contains the inventory id, why?
Thank you in advance for the feedback.
I'm trying to use a thread to retrieve inventory level information from a db, and store it in a map. Below I have included the struct from the header file, and the call to the thread. I am initializing the structure with an inventory item id, and date range prior to the thread call. However, once inside the thread the information pointed to in the structure is no longer available. Can anybody see what I'm doing wrong, or does anybody have a different recommended approach?
Code:
// header file
typedef struct _InvDetail
{
CString csInvID;
CString csFromDt;
CString csToDt;
float fPurchased;
float fXfer;
float fBeginInv;
} InvDetail, *PtrInvDetail;
// code snippet ----------------------------
PtrInvDetail pInvDetail = new InvDetail;
pInvDetail->csInvID = csInvID;
pInvDetail->csFromDt = dtBusDate.Format();
pInvDetail->csToDt = csUpdDate;
m_mapInvDetail.SetAt(csInvID, pInvDetail);
AfxBeginThread(ThreadInvDetail, (LPVOID)&pInvDetail);
}
UINT ThreadInvDetail(LPVOID pParam)
{
InvDetail* pInvDetail = (InvDetail*)pParam;
// end of snippet
pInvDetail->csInvID no longer contains the inventory id, why?
Thank you in advance for the feedback.