Thank You very much Keith!
Your suggestion was very helpfull. What I came to, waiting for an answer,
was putting in my routine as "pause" those lines:
Do Until (sRetData <> "" Or bTimeout = True)
Loop
But as You, of course, know it just could not work. Then came Your post and
"eureka"!
App.DoEvents() was the key! :) Thank You once more!
Essential frgment of the routine now looks like this:
Do Until (sRetData <> "" Or bTimeout = True)
App.DoEvents()
Loop
I have also one question concerning Timer class. I have custom class just to
manage those serial devices I mentioned in my first post. For the
initialization routine I would like to create object of the Timer class for
the control of serial connection timeouts (I can't find anything about
timeouts for Serial class in documentation) and I have to do it manually.
How can I set 'Action' event for such manual Timer. My current solution is
to use the Timer object which is another property of Window object. But this
is not an elegant way to do it, I suppose, because this timer is needed only
in the custom class and this class lays even one step lower in the class
hierarchy so I have to use constructions like "MainWindow.MyTimer.Enabled =
True" to control the timer.
Once more I would be grateful for help.
Regards,
Pawel
----- Original Message -----
From: "Keith Bennett" <[EMAIL PROTECTED]>
To: "Getting Started" <gettingstarted@lists.realsoftware.com>
Sent: Tuesday, June 13, 2006 8:33 PM
Subject: Re: Pause ver. 2.0
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>
_______________________________________________
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>