在指定條件集合變為 true 之前,會封鎖執行。這用於搭配 parallel 任務,以同步處理程序集合。
等待的條件定義在 巢狀元素 中,如果指定多個條件,則任務會等到所有條件都為 true。
如果未指定 maxwait 和 maxwaitunit,預設 maxwait 為 3 分鐘 (180000 毫秒)。
如果已設定 timeoutproperty 屬性,則在條件未在指定時間內變為 true 時,會建立一個具有該名稱的屬性。
屬性 | 說明 | 必要 |
---|---|---|
maxwait | 在任務失敗之前,等待所有必要條件變為 true 的最長時間。 | 否;預設為 180000 maxwaitunits |
maxwaitunit | 必須用於詮釋 maxwait 屬性值的時間單位。有效值為
|
否;預設為 millisecond |
checkevery | 每次測試條件之間的等待時間。 | 否;預設為 500 checkeveryunits |
checkeveryunit | 必須用於詮釋 checkevery 屬性值的時間單位。有效值為
|
否;預設為 millisecond |
timeoutproperty | 如果已超過 maxwait,則要設定的屬性名稱。 | 否 |
符合 <waitfor>
任務的可用條件與 <condition>
任務的條件相同。請參閱 此處,以取得完整清單。
等待最多 30 秒,直到出現名為 errors.log 的檔案。
<waitfor maxwait="30" maxwaitunit="second"> <available file="errors.log"/> </waitfor>
等待最多 3 分鐘 (並每 500 毫秒檢查一次),直到 localhost 上的網頁伺服器提供指定的 URL。
<waitfor maxwait="3" maxwaitunit="minute" checkevery="500"> <http url="https://127.0.0.1/myapp/index.html"/> </waitfor>
等待最多 10 秒鐘,直到 dbserver 電腦上的伺服器開始在 1521 埠傾聽,以及 https://webserver/mypage.html 網頁可供使用。
<waitfor maxwait="10" maxwaitunit="second"> <and> <socket server="dbserver" port="1521"/> <http url="https://webserver/mypage.html"/> </and> </waitfor>