Listening for an event in the middle of a function/sub
Posted on 2003-02-26
Is there a way to listen for an event in the middle of a function or subroutine? Or better yet to wait for an event to occur before continuing on?
I have a fairly complex program but in the heart of it I am making a connection to a server (using winsock) and running some commands to get some information about accounts on the server.
The only problem I am running into is that there is no way to pause the program long enough for the remote server to send a response. I know I can use the event functions (winsock_DataArrival) to determine what I want to do when an event occurs, but using those entirely means I end up with some really bad spagetti code. I would like to to something like this:
LogonToServer 'Handles all of the sign on procedures
For ifor = 0 To 30
winsock.SendData "/accountdata " & aAccount(ifor)
'wait for a response from server.. this is what I can't do
That was just a rough idea of what I am trying to do, anyone have any ideas? Or is this not possible at all?