Thread: Threads...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>There was only the ability to pass the thread a parameter of type LPVOID, which really does nothing for me.

    You can use the LPVOID to pass a pointer to a structure which you share between the main thread and worker thread. The worker thread can write to variables in the shared struct, while the main thread reads from it. You'll need thread synchronization to prevent bad things from happening; for example, pass an Event in the structure, so that the thread can signal the main program when it's finished processing a certain segment of data, and the main program can then read the result from another member of the structure.

    Et cetera.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #2
    Registered User
    Join Date
    Mar 2006
    Location
    USA::Colorado
    Posts
    155
    Quote Originally Posted by Hunter2 View Post
    >>There was only the ability to pass the thread a parameter of type LPVOID, which really does nothing for me.

    You can use the LPVOID to pass a pointer to a structure which you share between the main thread and worker thread. The worker thread can write to variables in the shared struct, while the main thread reads from it. You'll need thread synchronization to prevent bad things from happening; for example, pass an Event in the structure, so that the thread can signal the main program when it's finished processing a certain segment of data, and the main program can then read the result from another member of the structure.

    Et cetera.
    Oh... That explains quite a lot. I'll do a quick google for synchronization.

    Quote Originally Posted by matsp
    You can get the "return value" from the thread by using the API GetExitCodeThread.
    If the above way fails, I'll give this a try.

    Thanks for the help everyone =]
    ~guitarist809~

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 10-17-2008, 11:28 AM
  2. Yet another n00b in pthreads ...
    By dimis in forum C++ Programming
    Replies: 14
    Last Post: 04-07-2008, 12:43 AM
  3. Classes and Threads
    By Halloko in forum Windows Programming
    Replies: 9
    Last Post: 10-23-2005, 05:27 AM
  4. problem with win32 threads
    By pdmarshall in forum C++ Programming
    Replies: 6
    Last Post: 07-29-2004, 02:39 PM
  5. Block and wake up certain threads
    By Spark in forum C Programming
    Replies: 9
    Last Post: 06-01-2002, 03:39 AM