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. Could AfxBeginThread not run in a dll?

Could AfxBeginThread not run in a dll?

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
11 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.
  • R rushing

    I create a mfc regular dll and run the AfxBeginThread function in it. As soon as I run this function ,there is a error . Why?

    R Offline
    R Offline
    Rage
    wrote on last edited by
    #2

    Can you post your code ? It surely comes from how you are calling it. ~RaGE();

    R 1 Reply Last reply
    0
    • R Rage

      Can you post your code ? It surely comes from how you are calling it. ~RaGE();

      R Offline
      R Offline
      rushing
      wrote on last edited by
      #3

      void CYiCltDllApp::Start() { m_proxyServer.bRun = TRUE; m_proxyServer.m_Info.hWnd = m_hWnd; m_proxyServer.m_Info.nPort = m_nPort; // local m_proxyServer.m_sitebase =m_sitebase; m_proxyServer.m_IpAddress =m_IpAddress; m_proxyServer.m_BufferRoot =m_RecvBuffer; if(m_hWnd!=NULL) { AfxBeginThread(StartThread, (LPVOID)&m_proxyServer, THREAD_PRIORITY_BELOW_NORMAL); } }

      R 1 Reply Last reply
      0
      • R rushing

        void CYiCltDllApp::Start() { m_proxyServer.bRun = TRUE; m_proxyServer.m_Info.hWnd = m_hWnd; m_proxyServer.m_Info.nPort = m_nPort; // local m_proxyServer.m_sitebase =m_sitebase; m_proxyServer.m_IpAddress =m_IpAddress; m_proxyServer.m_BufferRoot =m_RecvBuffer; if(m_hWnd!=NULL) { AfxBeginThread(StartThread, (LPVOID)&m_proxyServer, THREAD_PRIORITY_BELOW_NORMAL); } }

        R Offline
        R Offline
        rushing
        wrote on last edited by
        #4

        After debug in StartThread function by set break point, I found that the program do not step into the StartThread function.

        R 2 Replies Last reply
        0
        • R rushing

          After debug in StartThread function by set break point, I found that the program do not step into the StartThread function.

          R Offline
          R Offline
          Rage
          wrote on last edited by
          #5

          Is StartThread declared as static ? ~RaGE();

          R 1 Reply Last reply
          0
          • R rushing

            After debug in StartThread function by set break point, I found that the program do not step into the StartThread function.

            R Offline
            R Offline
            Rage
            wrote on last edited by
            #6

            What is returned by AfxBeginThread ? Does it help to set the priority to THREAD_PRIORITY_NORMAL ? ~RaGE();

            R 1 Reply Last reply
            0
            • R Rage

              Is StartThread declared as static ? ~RaGE();

              R Offline
              R Offline
              rushing
              wrote on last edited by
              #7

              not static. At first,I set it as a member of CYiCltDllApp. Then set it as a independent function.

              R 1 Reply Last reply
              0
              • R Rage

                What is returned by AfxBeginThread ? Does it help to set the priority to THREAD_PRIORITY_NORMAL ? ~RaGE();

                R Offline
                R Offline
                rushing
                wrote on last edited by
                #8

                the return of AfxBeginThread is not null.

                R 1 Reply Last reply
                0
                • R rushing

                  not static. At first,I set it as a member of CYiCltDllApp. Then set it as a independent function.

                  R Offline
                  R Offline
                  Rage
                  wrote on last edited by
                  #9

                  Then try and define it static. You will have to pass the this pointer as a parameter to get hold on your data. ~RaGE();

                  1 Reply Last reply
                  0
                  • R rushing

                    the return of AfxBeginThread is not null.

                    R Offline
                    R Offline
                    Rage
                    wrote on last edited by
                    #10

                    If it is not null, then the thread was created (AfxBeginThread returns a CWinThread object). ~RaGE();

                    R 1 Reply Last reply
                    0
                    • R Rage

                      If it is not null, then the thread was created (AfxBeginThread returns a CWinThread object). ~RaGE();

                      R Offline
                      R Offline
                      rushing
                      wrote on last edited by
                      #11

                      Thank you very much! Set static function is ok.

                      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