   Issues using WaitForSingleObject
  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.0Thanks and Regards,Rohith H N   
  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;Quote:Original post by RohithzhereHi 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.0Thanks and Regards,Rohith H N99% of chance that your code is dead-locking somewhere! Try to examine the code that should signal that event...   ;  @Black NightYes the code hangs there. The Time Out parameter was INFINITE which i changed to 5 msBut Still it didn't seem to work.@feal87Ok, 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;Quote:Original post by RohithzhereAlso to make things clearer, I am using VC 6.0I'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 RohithzhereYes the code hangs there. The Time Out parameter was INFINITE which i changed to 5 msBut 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 RohithzhereOk, 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?   