Thread: Calling a Thread with a Function Pointer.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    >The obvious difference is that the Thread Function I am trying to convert is using a windows calling convention and is returning a unsigned long. I want my Create function to have the flexiblity to handle, for the most part any type of thread function thrown at it

    I'm not sure you can do that. Can't you just have the function you pass to CreateThread call another function? Maybe something along the lines of:
    Code:
    struct FooStruct
    {
      int a, b, c;
    };
    
    void FooThreadProc(int a, int b, int c)
    {
    //...
    }
    DWORD WINAPI FooThreadStartProc(LPVOID params)
    {
      FooStruct* fs = reinterpret_cast<FooStruct*>(params);
      FooThreadProc(fs->a,fs->b,fs->c);
    }
    And your class isn't a singleton. There isn't even a static function in it
    Last edited by JaWiB; 06-09-2006 at 09:20 PM. Reason: Syntax errors
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  2. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  3. What is a virtual function pointer?
    By ting in forum C++ Programming
    Replies: 4
    Last Post: 03-05-2008, 02:36 AM
  4. calling a function with a pointer to a struct
    By bomberto in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2006, 04:21 AM
  5. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM