Thread: Threads problem

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    589

    Threads problem

    Ok I am getting sleepy and I can't see the code for all letters. I am trying to run a thread but I get a compiler error
    Code:
    UINT CBarjorCadCamView::CreatePointMenu(LPVOID pParam)
    {
        CBarjorCadCamView* pObject = (CBarjorCadCamView*pParam;
    
        if (pObject == NULL ||
            !pObject->IsKindOf(RUNTIME_CLASS(CBarjorCadCamView)))
        return 1;   // if pObject is not valid
    
        // do something with 'pObject'
    
        return 0;   // thread completed successfully
    }
    
    //And I call it like this
    
    void CBarjorCadCamView::OnTest() 
    {
    	CBarjorCadCamView*pNewObject = new CBarjorCadCamView;
    	AfxBeginThread(CreatePointMenu, pNewObject);
    }
    The error I get is
    F:\My Programs\InProgres\BarjorCadCam\BarjorCadCamView.c pp(2826) : error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'

    Do I have to start the thread in another class then View?
    Can the "thread function" be in the ViewClass?

    So I am stuck . Any help would be so great and I would gladly give my old keyboard as a reward, well maybe not.
    Last edited by Barjor; 03-12-2002 at 10:08 PM.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    In your class declaration, declare the thread func like so;

    Code:
    static UINT CreatePointMenu(LPVOID pParam);
    or in your code detail the function as a non class member;

    Code:
    UINT CreatePointMenu(LPVOID pParam);

    That sould work, you can keep the keyboard.......

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    589
    Worked like a charm. Thanks alot..Mm no keyboard..How about a Govtcheez doll in fair shape?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  2. Closing threads
    By VirtualAce in forum Windows Programming
    Replies: 8
    Last Post: 01-02-2006, 10:49 AM
  3. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  5. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM