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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Need help with Worker Thread Code

Need help with Worker Thread Code

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestioncom
3 Posts 3 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.
  • F Offline
    F Offline
    Freddie Code
    wrote on last edited by
    #1

    I'm a newbee with MFC. I'm following this article on Worker Threads: http://www.codeproject.com/threads/usingworkerthreads.asp[^] With the following code I'm getting the following error. Any suggestions as to what is going on here? : error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'void (void)' // getcanmessages.cpp: implementation of the Cgetcanmessages class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "canmon.h" #include "getcanmessages.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// static UINT run(LPVOID p); void run(); volatile BOOL running; Cgetcanmessages::Cgetcanmessages() { } Cgetcanmessages::~Cgetcanmessages() { } void Cgetcanmessages::gogetcan() { running = TRUE; AfxBeginThread(run, this); //<<<---this is the error line. } UINT Cgetcanmessages::run(LPVOID p) { Cgetcanmessages * me = (Cgetcanmessages *)p; me->run(); return 0; } void Cgetcanmessages::run() { //add worker tasks here. }

    D K 2 Replies Last reply
    0
    • F Freddie Code

      I'm a newbee with MFC. I'm following this article on Worker Threads: http://www.codeproject.com/threads/usingworkerthreads.asp[^] With the following code I'm getting the following error. Any suggestions as to what is going on here? : error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'void (void)' // getcanmessages.cpp: implementation of the Cgetcanmessages class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "canmon.h" #include "getcanmessages.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// static UINT run(LPVOID p); void run(); volatile BOOL running; Cgetcanmessages::Cgetcanmessages() { } Cgetcanmessages::~Cgetcanmessages() { } void Cgetcanmessages::gogetcan() { running = TRUE; AfxBeginThread(run, this); //<<<---this is the error line. } UINT Cgetcanmessages::run(LPVOID p) { Cgetcanmessages * me = (Cgetcanmessages *)p; me->run(); return 0; } void Cgetcanmessages::run() { //add worker tasks here. }

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      See here.


      "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

      1 Reply Last reply
      0
      • F Freddie Code

        I'm a newbee with MFC. I'm following this article on Worker Threads: http://www.codeproject.com/threads/usingworkerthreads.asp[^] With the following code I'm getting the following error. Any suggestions as to what is going on here? : error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'void (void)' // getcanmessages.cpp: implementation of the Cgetcanmessages class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "canmon.h" #include "getcanmessages.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// static UINT run(LPVOID p); void run(); volatile BOOL running; Cgetcanmessages::Cgetcanmessages() { } Cgetcanmessages::~Cgetcanmessages() { } void Cgetcanmessages::gogetcan() { running = TRUE; AfxBeginThread(run, this); //<<<---this is the error line. } UINT Cgetcanmessages::run(LPVOID p) { Cgetcanmessages * me = (Cgetcanmessages *)p; me->run(); return 0; } void Cgetcanmessages::run() { //add worker tasks here. }

        K Offline
        K Offline
        khan
        wrote on last edited by
        #3

        Freddie Code wrote: static UINT run(LPVOID p); void run(); volatile BOOL running; I suggest you rename the second function above. There are two functions named run(). One is UINT run(LPVOID) and the other is void run(). Rename the void run() to anything else because the compiler is getting confused. this is this.

        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