Jump to content
  • Advertisement
Sign in to follow this  
Rohithzhere

Issues using WaitForSingleObject

This topic is 3320 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 am a little new to MFC .I am ok at C++ though i am not yet strong in concepts like threading ,crictical section et al . I am now working on a project which contains a lot of MFC code written by someone else. I ported that code to a machine which had a dual core processor and now, most of the times one of the application's threads stops responding. I did dig down the code and found out the a function named WaitForSingleObject is not returning any value(Sometimes it works fine though) . But in the other machine which had a single core this code used to work fine. I am not able to understand as to why this is happening. Can any1 kindly give me some guidance regarding this issue. Also to make things clearer, I am using VC 6.0 Thanks and Regards, Rohith H N

Share this post


Link to post
Share on other sites
Advertisement
By "WaitForSingleObject is not returning any value", I guess you mean it hangs there.Is there a timeout interval given for the second parameter of WaitForSingleObject? If it is INFINITE as MSDN says it will wait forever until the object is signaled.

More info on WaitForSingleObject

Share this post


Link to post
Share on other sites
Quote:
Original post by Rohithzhere
Hi all,

I am a little new to MFC .I am ok at C++ though i am not yet strong in concepts like threading ,crictical section et al . I am now working on a project which contains a lot of MFC code written by someone else.

I ported that code to a machine which had a dual core processor and now, most of the times one of the application's threads stops responding. I did dig down the code and found out the a function named WaitForSingleObject is not returning any value(Sometimes it works fine though) . But in the other machine which had a single core this code used to work fine. I am not able to understand as to why this is happening.

Can any1 kindly give me some guidance regarding this issue.
Also to make things clearer, I am using VC 6.0


Thanks and Regards,
Rohith H N


99% of chance that your code is dead-locking somewhere! Try to examine the code that should signal that event...

Share this post


Link to post
Share on other sites
@Black Night

Yes the code hangs there.
The Time Out parameter was INFINITE which i changed to 5 ms
But Still it didn't seem to work.


@feal87

Ok, But i 've never worked on critical sections,semaphores and stuff like that.
How Difficult would it be to learn it?


Thanks and Regards,
Rohith H N

Share this post


Link to post
Share on other sites
Quote:
Original post by Rohithzhere
Also to make things clearer, I am using VC 6.0
I'd highly recommend getting rid of VC 6.0 and using a compiler that's less than 10 years old. VC 6 is horribly broken in some areas.

Quote:
Original post by Rohithzhere
Yes the code hangs there.
The Time Out parameter was INFINITE which i changed to 5 ms
But Still it didn't seem to work.
You're changing the way the code works by doing that. I wouldn't do that unless you know what you're doing.

Quote:
Original post by Rohithzhere
Ok, But i 've never worked on critical sections,semaphores and stuff like that.
How Difficult would it be to learn it?
Not that difficult.

WaitForSingleObject() waits for the handle to become signalled. The handle can become signalled through a number of methods, usually by using SetEvent() for events, or if the handle is a thread handle, then the handle becomes signalled when the thread exits. There's a crapload of different ways for a handle to become signalled, it depends on what the handle is.
Where is the handle first allocated? What function is the handle created by?

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!