Creating Thread in DLL
-
Hi I am writing a Regular DLL in which i am creating a Thread by using the function extern "C" __declspec(dllexport) BOOL ReadCard(char *pData) { if(l_hPort == NULL) { strcpy(pData,"COM port is null"); return FALSE; } memset(g_strResult,0x00,500); //PrepareThread(pData); g_hThreadRead = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) MyMSR_PortReadThreadMgr,(LPVOID)&pData, 0,&dwThreadID); } I have declared the function at the top but when i call this DLL from some other application it is working fine but it is not going to the function i have in CreateThread means it is not going on the function MyMSR_PortReadThreadMgr(); Please tell me whats wrong with this. I have created the project using Regular DlL in which i have inserted one file PrintPad.cpp and PrintPad.h in which i am writing these functions. My Function is as: static UINT MyMSR_PortReadThreadMgr(LPVOID pData) { BOOL bSuccess = TRUE; while(1) { if ( l_bTaskAbort ) { Disconnect(); return(FALSE); } // if the card is removed then read the data if( !GetCardData()) { strcpy((char*)pData,"No Data Received"); Rs232CleanUp(FALSE); return FALSE; } if(strncmp(g_strResult,"{N}",3) == 0) { //strcpy(pData,"No Data Received."); Rs232CleanUp(FALSE); return FALSE; } if(strstr(g_strResult, "T1:B") || strstr(g_strResult, "T2:B") || strstr(g_strResult, "T3:B")) { // strcpy(pData,"bad track Read"); Rs232CleanUp(FALSE); return FALSE; } }// end of while return bSuccess; }
-
Hi I am writing a Regular DLL in which i am creating a Thread by using the function extern "C" __declspec(dllexport) BOOL ReadCard(char *pData) { if(l_hPort == NULL) { strcpy(pData,"COM port is null"); return FALSE; } memset(g_strResult,0x00,500); //PrepareThread(pData); g_hThreadRead = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) MyMSR_PortReadThreadMgr,(LPVOID)&pData, 0,&dwThreadID); } I have declared the function at the top but when i call this DLL from some other application it is working fine but it is not going to the function i have in CreateThread means it is not going on the function MyMSR_PortReadThreadMgr(); Please tell me whats wrong with this. I have created the project using Regular DlL in which i have inserted one file PrintPad.cpp and PrintPad.h in which i am writing these functions. My Function is as: static UINT MyMSR_PortReadThreadMgr(LPVOID pData) { BOOL bSuccess = TRUE; while(1) { if ( l_bTaskAbort ) { Disconnect(); return(FALSE); } // if the card is removed then read the data if( !GetCardData()) { strcpy((char*)pData,"No Data Received"); Rs232CleanUp(FALSE); return FALSE; } if(strncmp(g_strResult,"{N}",3) == 0) { //strcpy(pData,"No Data Received."); Rs232CleanUp(FALSE); return FALSE; } if(strstr(g_strResult, "T1:B") || strstr(g_strResult, "T2:B") || strstr(g_strResult, "T3:B")) { // strcpy(pData,"bad track Read"); Rs232CleanUp(FALSE); return FALSE; } }// end of while return bSuccess; }