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. MFC + Threading = C2665

MFC + Threading = C2665

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studioquestion
7 Posts 4 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.
  • K Offline
    K Offline
    Killiconn
    wrote on last edited by
    #1

    I have been surfing the web trying to find a solution and I've tried some of them and still can't compile. It is a standard VS generated DlgClass and I just want to launch the worker which is prototyped up top as global. I've tried casting ExecuteThread every way possible pretty much in the thread launch function. Any obvious solutions?

    // Prototypes:
    void ExecuteThread(LPVOID lParam)

    // Button to launch the worker:
    void CVisualEmulatorDlg::OnBnClickedRun()
    {
    HWND hWnd = GetSafeHwnd();

    CWinThread \*pThread = AfxBeginThread(ExecuteThread, hWnd, THREAD\_PRIORITY\_NORMAL);
    
    //cpu->Execute();
    

    }

    // Worker Thread:
    void ExecuteThread(LPVOID lParam)
    {

        //cpu->Execute();
    
    MessageBox( (HWND)lParam, (LPCWSTR)"Thread Start", (LPCWSTR)"Secondary Thread", MB\_OK );
    return;
    

    }

    _ _ S 3 Replies Last reply
    0
    • K Killiconn

      I have been surfing the web trying to find a solution and I've tried some of them and still can't compile. It is a standard VS generated DlgClass and I just want to launch the worker which is prototyped up top as global. I've tried casting ExecuteThread every way possible pretty much in the thread launch function. Any obvious solutions?

      // Prototypes:
      void ExecuteThread(LPVOID lParam)

      // Button to launch the worker:
      void CVisualEmulatorDlg::OnBnClickedRun()
      {
      HWND hWnd = GetSafeHwnd();

      CWinThread \*pThread = AfxBeginThread(ExecuteThread, hWnd, THREAD\_PRIORITY\_NORMAL);
      
      //cpu->Execute();
      

      }

      // Worker Thread:
      void ExecuteThread(LPVOID lParam)
      {

          //cpu->Execute();
      
      MessageBox( (HWND)lParam, (LPCWSTR)"Thread Start", (LPCWSTR)"Secondary Thread", MB\_OK );
      return;
      

      }

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      You haven't been reading your documentation!!! ;P Try this.

      UINT __cdecl ExecuteThread( LPVOID pParam );

      «_Superman_» I love work. It gives me something to do between weekends.

      K 1 Reply Last reply
      0
      • K Killiconn

        I have been surfing the web trying to find a solution and I've tried some of them and still can't compile. It is a standard VS generated DlgClass and I just want to launch the worker which is prototyped up top as global. I've tried casting ExecuteThread every way possible pretty much in the thread launch function. Any obvious solutions?

        // Prototypes:
        void ExecuteThread(LPVOID lParam)

        // Button to launch the worker:
        void CVisualEmulatorDlg::OnBnClickedRun()
        {
        HWND hWnd = GetSafeHwnd();

        CWinThread \*pThread = AfxBeginThread(ExecuteThread, hWnd, THREAD\_PRIORITY\_NORMAL);
        
        //cpu->Execute();
        

        }

        // Worker Thread:
        void ExecuteThread(LPVOID lParam)
        {

            //cpu->Execute();
        
        MessageBox( (HWND)lParam, (LPCWSTR)"Thread Start", (LPCWSTR)"Secondary Thread", MB\_OK );
        return;
        

        }

        _ Offline
        _ Offline
        _AnsHUMAN_
        wrote on last edited by
        #3

        Killiconn wrote:

        void ExecuteThread(LPVOID lParam)

        Are you missing the ';' behind the function declaration. By the way what are the compilation errors that you get? The possible solutions for C2665 are * Supply a conversion operator. * Use explicit conversion. but can't really say if they help you in resolving your problem

        You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_

        1 Reply Last reply
        0
        • K Killiconn

          I have been surfing the web trying to find a solution and I've tried some of them and still can't compile. It is a standard VS generated DlgClass and I just want to launch the worker which is prototyped up top as global. I've tried casting ExecuteThread every way possible pretty much in the thread launch function. Any obvious solutions?

          // Prototypes:
          void ExecuteThread(LPVOID lParam)

          // Button to launch the worker:
          void CVisualEmulatorDlg::OnBnClickedRun()
          {
          HWND hWnd = GetSafeHwnd();

          CWinThread \*pThread = AfxBeginThread(ExecuteThread, hWnd, THREAD\_PRIORITY\_NORMAL);
          
          //cpu->Execute();
          

          }

          // Worker Thread:
          void ExecuteThread(LPVOID lParam)
          {

              //cpu->Execute();
          
          MessageBox( (HWND)lParam, (LPCWSTR)"Thread Start", (LPCWSTR)"Secondary Thread", MB\_OK );
          return;
          

          }

          S Offline
          S Offline
          Sunil Lanke
          wrote on last edited by
          #4

          Your worker thread function definition is wrong, check out here[^] The function should not return void, the function signature should be as follows: UINT __cdecl MyControllingFunction( LPVOID pParam );

          1 Reply Last reply
          0
          • _ _Superman_

            You haven't been reading your documentation!!! ;P Try this.

            UINT __cdecl ExecuteThread( LPVOID pParam );

            «_Superman_» I love work. It gives me something to do between weekends.

            K Offline
            K Offline
            Killiconn
            wrote on last edited by
            #5

            The reason I ended up trying void, along with any other things is that UNIT dosn't show up as a data type. Is there a header that needs to be included? Having trouble researching it because everything that comes back is about unit testing. From one page it looked like UNIT meant use, int, long, or short, but tried and non of those worked. Tried with and without the __cdecl as well. Never come across the UNIT before and wishing right now I never had. Code looks basically the same. Any ideas?

            // Launcher
            void CVisualEmulatorDlg::OnBnClickedRun()
            {
            HWND hWnd = GetSafeHwnd();

            CWinThread \*pThread = AfxBeginThread(ExecuteThread, hWnd, THREAD\_PRIORITY\_NORMAL);
            
            //cpu->Execute();
            

            }

            // Worker
            UNIT __cdecl ExecuteThread(LPVOID lParam)
            {
            MessageBox( (HWND)lParam, (LPCWSTR)"Thread Start", (LPCWSTR)"Secondary Thread", MB_OK );
            }

            _ 1 Reply Last reply
            0
            • K Killiconn

              The reason I ended up trying void, along with any other things is that UNIT dosn't show up as a data type. Is there a header that needs to be included? Having trouble researching it because everything that comes back is about unit testing. From one page it looked like UNIT meant use, int, long, or short, but tried and non of those worked. Tried with and without the __cdecl as well. Never come across the UNIT before and wishing right now I never had. Code looks basically the same. Any ideas?

              // Launcher
              void CVisualEmulatorDlg::OnBnClickedRun()
              {
              HWND hWnd = GetSafeHwnd();

              CWinThread \*pThread = AfxBeginThread(ExecuteThread, hWnd, THREAD\_PRIORITY\_NORMAL);
              
              //cpu->Execute();
              

              }

              // Worker
              UNIT __cdecl ExecuteThread(LPVOID lParam)
              {
              MessageBox( (HWND)lParam, (LPCWSTR)"Thread Start", (LPCWSTR)"Secondary Thread", MB_OK );
              }

              _ Offline
              _ Offline
              _Superman_
              wrote on last edited by
              #6

              typo typo typo typo Its UINT not UNIT.

              «_Superman_» I love work. It gives me something to do between weekends.

              K 1 Reply Last reply
              0
              • _ _Superman_

                typo typo typo typo Its UINT not UNIT.

                «_Superman_» I love work. It gives me something to do between weekends.

                K Offline
                K Offline
                Killiconn
                wrote on last edited by
                #7

                Wow.. sorry guys. Pretty embarased right now...but that fixed it. Thanks a lot.

                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