首页 > lang > wait 
 en fr de es it nl pl pt pt_BR mk sq ca hu cs tr ar fa id vi ko ja ru zh eo
前一个  下一个  编辑  重命名  撤销  搜索  管理  
文档  
警告! 该页面未翻译。  参见英文版 
WAIT
WAIT [ Delay ]

Calls recursively the event loop.

If Delay is specified, the function does not return until Delay seconds elapse.

If Delay is not specified, the function processes all pending events and returns immediately. In that specific case, input events (keyboard and mouse) are ignored.

Delay is a floating point number. So, if you want to wait 100 ms, just do: WAIT 0.1

Example

' Waits a little, letting the user interacts with the GUI
WAIT 0.1

' Waits, but the user can just watch what happens...
WAIT

If you call WAIT from an event handler, you may create infinite recursions, and then stack overflows.

For example, look at the following code:

PUBLIC SUB MySerialPort_Read()

  DIM sData, sTemp AS String
  DIM iTries AS Integer

  FOR iTries = 1 TO 5
    ' wait a bit and read response.
    WAIT 0.01
    ' see if we got some data.
    READ #LAST, sTemp, Lof(LAST)
    sData &= sTemp
    ...
 NEXT

END

WAIT is called without reading anything on the serial port. So it is yet ready for being read, and the Read event is raised recursively again and again until the stack is full.

In that case, you can solve the problem by using the SLEEP instruction instead.

参见

Event Loop