BeginThreadex problems!

I am a beginner and this is my first attempt at multi threading and I'm trying to get it so that it will use threads to generate the image.

void Image() does all the image calculating, that seems to be okay I'm getting all my problems in ImageTexture().

Could anyone have a look at my code and tell me where I'm going wrong?

Thanks alot

Last edited on
You're using WaitForMultipleObjects incorrectly.

The 2nd parameter should be a pointer to an array of HANDLEs. I'm not entirely familiar with the function, but it seems to me that if you want to wait for 16 threads to finish, you have to give WaitForMultipleObjects a pointer to an array containing all 16 HANDLEs for all the threads you want to wait for.

And for that matter... you are trying to wait for all 16 threads inside the loop..... so it will start waiting after only 1 thread has been created. That's probably not what you wanted.

Furthermore... I'm not entirely sure _beginthreadex returns a HANDLE, so your cast on line 64 might be bad. According to the msdn page it returns a uintptr_t which is probably castable to a HANDLE but I don't know if it represents the same thing or not.

Also... why are you passing &myData to CloseHandle? myData isn't a HANDLE, so what exactly are you trying to close?

Also according to the docs I'm reading on MSDN, _beginthreadex only takes 6 parameters, not 7... so I don't see how this would even be compiling.

And a stack size of 16 bytes? That's waaaaaay too small to do anything. Just use the default stack size.
Last edited on
Topic archived. No new replies allowed.