Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Creating Thread in DLL

Creating Thread in DLL

Scheduled Pinned Locked Moved C / C++ / MFC
c++com
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aman2006
    wrote on last edited by
    #1

    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; }

    O 1 Reply Last reply
    0
    • A aman2006

      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; }

      O Offline
      O Offline
      oustar
      wrote on last edited by
      #2

      I think you should test the return values of "CreateThread".:) GOOD LUCK.

      A 1 Reply Last reply
      0
      • O oustar

        I think you should test the return values of "CreateThread".:) GOOD LUCK.

        A Offline
        A Offline
        aman2006
        wrote on last edited by
        #3

        it is creating the thread but not going to the function?? Can you tell me the reason.. shailesh

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups