how to create a new thread in c++ class: why i can not get output.

Discussion in 'C++' started by sun4216, Aug 25, 2003.

  1. sun4216

    sun4216 Guest

    the program is below, I print a string in the new thread ,but ir seems
    nothing had happened : why ? can anybody tell me ? you help will alway
    appreciate .

    //main.cpp:
    #include "stdio.h"

    #include "program.h"
    void main()
    {
    CProgram Prog;
    Prog.ReadChip (88);
    }

    //program.h:
    #include <windows.h>
    #include "usb.h"

    class CProgram
    {
    public:
    CProgram();
    virtual ~CProgram();
    BOOL ReadChip(int readLen);
    static DWORD WINAPI Read(LPVOID lpParam);
    };


    //program.cpp:
    #include "Program.h"
    #include "stdio.h"

    CProgram::CProgram()
    {
    }
    CProgram:: ~CProgram()
    {
    }

    BOOL CProgram::ReadChip(int readLen)
    {
    DWORD ThreadIDProgram;
    CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)Read,
    (LPVOID)&readLen, 0, (LPDWORD)&ThreadIDProgram);
    return 1;
    }

    DWORD WINAPI CProgram::Read(LPVOID lpParam)
    {
    printf("lpParam is:%d", *(int*)lpParam);
    return 1;
    }
    sun4216, Aug 25, 2003
    #1
    1. Advertising

  2. sun4216 wrote:
    > the program is below, I print a string in the new thread ,but ir seems
    > nothing had happened : why ? can anybody tell me ? you help will alway
    > appreciate .


    <snip>

    Please ask this question in a Microsoft/Visual C++ newsgoup, as the
    question is not relavent here.




    --


    http://www.it-is-truth.org/
    Asfand Yar Qazi, Aug 25, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Aditi
    Replies:
    2
    Views:
    1,427
    Aditi
    Jun 24, 2005
  2. chuck amadi
    Replies:
    1
    Views:
    477
    Larry Bates
    Jun 23, 2004
  3. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    853
    Mark Rae
    Dec 21, 2006
  4. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,739
    Smokey Grindel
    Dec 2, 2006
  5. grocery_stocker
    Replies:
    3
    Views:
    338
    Carl Banks
    Apr 10, 2009
Loading...

Share This Page