What you could do is to create a function called WaitUntilSomethingIsDone,
then in that function you simply poll whatever it is you're waiting for, and
only return when it's finished. Then in the function that you want to pause,
you call that function.

An example of WaitUntilSomethingIsDone, using UserCancelled:

Sub WaitUntilSomethingIsDone()
 While UserCancelled = False
   App.DoEvents() // this is *NOT* compatible with threads! you should use
App.SleepCurrentThread() if you plan to do this in a thread!
 Wend
End Sub

Another example, using a socket:
(MySocket is a Socket, with a property MySocket.ReceivedSomething As
Boolean, it is assumed that ReceivedSomething is set in the
MySocket.DataAvailable event)
Sub MySocket.WaitUntilSocketReceivedSomething()
 While Me.ReceivedSomething = False
   App.DoEvents() // this is *NOT* compatible with threads! you should use
App.SleepCurrentThread() if you plan to do this in a thread!
 Wend
End Sub

Hope this helps.



On 6/13/06, Pawel Modzelewski <[EMAIL PROTECTED]> wrote:

Hello,
I've question quite similar to the previous topic. What I want is to pause
some method in which serial communications is proccessed until the answer
arrives. It goes something like that:

  For i As Integer = 0 To 255
    Write(serialCommand)
    XmitWait

    {PAUSE until there is an answer from some serial device}

    If sRetData Than
        device = new Device(Hex(I))
        aDevices.Append device
    End If
  Next

In DataAvailable event handler I have:
    sRetData = ReadAll

sRetData is the very same class properity

To explain the situation a bit more : I have automated controller
connected
to the serial port of the host computer. Some more devices are connected
to
that controller to create measuring network. Each device has an address. I
can control each device directly with ASCII commands when I know it's
address. The routine above is to initilaze such network during application
start (because devices changes from time to time) to know what devices
work
and on what addresses. When I try this routine without the pause it return
with the information that there is no device connected and I suppose it is
because any device is even able to answer while the main loop finishes.
I have to say that I'm totally RB newbie so please forgive me if the
problem
is trivial.
I would be very grateful for any help, best regards
Pawel

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>




--
Keith Bennett, tA-Kane
Software developer and Macintosh enthusiast

Free iPods!!!
http://www.freeiPods.com/?r=10867472
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to