Jump to content
  • Advertisement
Sign in to follow this  
spookycat

WaitForMultipleObjects Problem!

This topic is 3260 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All I have a strange problem with WaitForMultipleObjects. If I try and do a wait on multiple objects with the line:
DWORD status = WaitForMultipleObjects(mDoneEvents.size(), &mDoneEvents[0], TRUE, INFINITE);
I get WAIT_FAILED returned with and Error of 87 Parameter Incorrect. The vector of HANDLE's is valid and if I do a WaitForSingleObject on each member of mDoneEvents all works fine, also if I set the bwaitAll flag to FALSE ie:
DWORD status = WaitForMultipleObjects(mDoneEvents.size(), &mDoneEvents[0], FALSE, INFINITE);
Then it works just fine, problem is I need the waitall to be TRUE, does anyone have any idea what I may have done wrong here? Many thanks Chris

Share this post


Link to post
Share on other sites
Advertisement
Is mDoneEvents an std::vector<HANDLE>?
Are they all the same type of objects, and how do you create them?
If you use FALSE for bWaitAll what is the return code?
And does it always return immediately, or can you actually get a blocking wait with FALSE for a while, if you don't signal the events?

My first action would be to inspect the vector of events, to make sure there are only four elements in it and that every handle is valid. Perhaps you have a duplicate?

From the documentation WaitForMultipleObjects:
Quote:

An array of object handles. For a list of the object types whose handles can be specified, see the following Remarks section. The array can contain handles to objects of different types. It may not contain multiple copies of the same handle.

If one of these handles is closed while the wait is still pending, the function's behavior is undefined.

The handles must have the SYNCHRONIZE access right. For more information, see Standard Access Rights.

Also read the Remarks section carefully.

Share this post


Link to post
Share on other sites
mDoneEvents is a std::vector<HANDLE> and I use
HANDLE event = CreateEvent(NULL, TRUE, FALSE, "Done");
mDoneEvents.push_back(event);



When I use FALSE for bwaitAll the return code is 0 and it will block correctly until a mDoneEvent is set, expected behaviour.

I should also say I would run this through the debugger to check but it's part of a plugin for 3ds max and that excludes the use of the debugger.

Checked the vector, its got 4 proper HANDLE's all different that work fine with WaitForSingleObject, SetEvent, ResetEvent etc so Iam assuming the HANDLE's are valid and havnt been corrupted.

Thanks for you suggestions, reading the MSDN page for the Nth time very carefully :)

Share this post


Link to post
Share on other sites
You should still be able to attach your debugger to the program. For example, with MSVC, if you load up your project and use Debug->Attach to Process you should be able to debug your own DLL code.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!