WaitForSingleObject not signaled
-
Hi I have a CAsynSocket as a member of a CwinThread (having each socket connection in its own thread) The program is acting as Client When I do a connect everything goes as a planned I get the OnConnect Notification and OnSend (though they always come in the context of the Main Thread). Since I would like to know when this happens I Wait on a CEvent. The CEvent is a member of the CwinThread. The only problem is that when I do the WaitForSingleObject nothing happens (as far as notification OnSend OnConnect)
-
Hi I have a CAsynSocket as a member of a CwinThread (having each socket connection in its own thread) The program is acting as Client When I do a connect everything goes as a planned I get the OnConnect Notification and OnSend (though they always come in the context of the Main Thread). Since I would like to know when this happens I Wait on a CEvent. The CEvent is a member of the CwinThread. The only problem is that when I do the WaitForSingleObject nothing happens (as far as notification OnSend OnConnect)
WaitForSingleObject will suspend the entire thread it's running in :-) So your OnSend and OnConnect code better not be on that thread or they will never be called which is what you are saying !!!!!!! It's called a deadlock the only thing that can release the WaitForSingleObject is an event that will never be sent because the detecting code to create the event will never run. Sounds to me like you need to get out a pen and paper again and work out the logic of the threads.
In vino veritas
-
WaitForSingleObject will suspend the entire thread it's running in :-) So your OnSend and OnConnect code better not be on that thread or they will never be called which is what you are saying !!!!!!! It's called a deadlock the only thing that can release the WaitForSingleObject is an event that will never be sent because the detecting code to create the event will never run. Sounds to me like you need to get out a pen and paper again and work out the logic of the threads.
In vino veritas
-
Hi I have a CAsynSocket as a member of a CwinThread (having each socket connection in its own thread) The program is acting as Client When I do a connect everything goes as a planned I get the OnConnect Notification and OnSend (though they always come in the context of the Main Thread). Since I would like to know when this happens I Wait on a CEvent. The CEvent is a member of the CwinThread. The only problem is that when I do the WaitForSingleObject nothing happens (as far as notification OnSend OnConnect)
First off let me say I am by trade a MainFrame Programer In Z/os you can issue a wait anywhere in a task or thread and it will suspend that unit of work or program. In MVS many programs comprise a task The program information is saved in a RB block But the task or Thread doesn't stop I understand this is not the case in Windows
-
First off let me say I am by trade a MainFrame Programer In Z/os you can issue a wait anywhere in a task or thread and it will suspend that unit of work or program. In MVS many programs comprise a task The program information is saved in a RB block But the task or Thread doesn't stop I understand this is not the case in Windows
You need to understand this isn't even about Windows you are using a framework and you need to understand the framework. Windows if you were dealing with the API can do some very different things and in your case the framework determines the behaviour because it was designed with a concept in mind. Since you seem to need proof the thread is blocked make the wait 10 seconds and look for the timeout
DWORD Ret=WaitForSingleObject(yourEvent, 10000);
if (Ret==WAIT_TIMEOUT)
{
TRACE("*** Houston we have a Timeout ... Thread blocked LdB right ***\n");
}If I am right you will get that message 10 seconds later .. so easy to test with 3 lines of code The solution is play nicely with CAsynSocket or go direct down onto the Windows API and do the socket work yourself. I don't doubt your programming ability just your understanding of the Framework.
In vino veritas
-
You need to understand this isn't even about Windows you are using a framework and you need to understand the framework. Windows if you were dealing with the API can do some very different things and in your case the framework determines the behaviour because it was designed with a concept in mind. Since you seem to need proof the thread is blocked make the wait 10 seconds and look for the timeout
DWORD Ret=WaitForSingleObject(yourEvent, 10000);
if (Ret==WAIT_TIMEOUT)
{
TRACE("*** Houston we have a Timeout ... Thread blocked LdB right ***\n");
}If I am right you will get that message 10 seconds later .. so easy to test with 3 lines of code The solution is play nicely with CAsynSocket or go direct down onto the Windows API and do the socket work yourself. I don't doubt your programming ability just your understanding of the Framework.
In vino veritas