## Waitfor

### Description

Blocks execution until a set of specified conditions become true. This is intended to be used with the parallel task to synchronize a set of processes.

The conditions to wait for are defined in nested elements, if multiple conditions are specified, then the task will wait until all conditions are true.

If both maxwait and maxwaitunit are not specified, default maxwait is 3 minutes (180000 milliseconds).

If the timeoutproperty attribute has been set, a property of that name will be created if the condition didn't come true within the specified time.

### Parameters

Attribute | Description | Required
--- | --- | ---
maxwait | The maximum amount of time to wait for all the required conditions to become true before failing the task. | No; defaults to 180000 maxwaitunits
maxwaitunit | The unit of time that must be used to interpret the value of the maxwait attribute. Valid values are millisecond second minute hour day week | No; defaults to millisecond
checkevery | The amount of time to wait between each test of the conditions. | No; defaults to 500 checkeveryunits
checkeveryunit | The unit of time that must be used to interpret the value of the checkevery attribute. Valid values are millisecond second minute hour day week | No; defaults to millisecond
timeoutproperty | the name of the property to set if maxwait has been exceeded. | No

### Parameters specified as nested elements

The available conditions that satisfy the `<waitfor>` task are the same as those for the `<condition>` task. See here for the full list.

### Examples

Wait up to 30 seconds for a file called `errors.log` to appear.

    <waitfor maxwait="30" maxwaitunit="second">
        <available file="errors.log"/>
    </waitfor>

Wait up to 3 minutes (and checks every 500 milliseconds) for a web server on `localhost` to serve up the specified URL.

    <waitfor maxwait="3" maxwaitunit="minute" checkevery="500">
        <http url="http://localhost/myapp/index.html"/>
    </waitfor>

Wait up to 10 seconds for a server on the `dbserver` machine to begin listening on port 1521 and for the `http://webserver/mypage.html` web page to become available.

    <waitfor maxwait="10" maxwaitunit="second">
        <and>
            <socket server="dbserver" port="1521"/>
            <http url="http://webserver/mypage.html"/>
        </and>
    </waitfor>