I need to send information over a Winsock TCP/IP connection and wait for a response before sending any further information. Here is my generalized function:
Private Sub LockingSend(s As String)
Do While m_bLocked
DoEvents
Loop
m_bLocked = True
Winsock.SendData s
Do While m_bLocked
DoEvents
Loop
End Sub
An event is called when they send back information, which sets m_bLocked to false. This seems to work when I do something like this:
LockingSend "Data1"
LockingSend "Data2"
LockingSend "Data3"
That is, the first one waits for it to finish before returning. The problem comes when the user hits a button or something and fires of an event which calls LockingSend as well. For whatever reason, this isn't getting blocked by the first loop. Any idea why?
What I really want to do is have a critical section that lets VB handle other events while it's waiting for EnterCriticalSection to return. Any ideas?
~BenDilts( void );
Private Sub LockingSend(s As String)
Do While m_bLocked
DoEvents
Loop
m_bLocked = True
Winsock.SendData s
Do While m_bLocked
DoEvents
Loop
End Sub
An event is called when they send back information, which sets m_bLocked to false. This seems to work when I do something like this:
LockingSend "Data1"
LockingSend "Data2"
LockingSend "Data3"
That is, the first one waits for it to finish before returning. The problem comes when the user hits a button or something and fires of an event which calls LockingSend as well. For whatever reason, this isn't getting blocked by the first loop. Any idea why?
What I really want to do is have a critical section that lets VB handle other events while it's waiting for EnterCriticalSection to return. Any ideas?
~BenDilts( void );