You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An timeout function which stops the Script execution.
194
-
It is similar to the conventional _setTimeout()_, which is not available in a Script Task.
193
+
A timeout function which pauses/postpones the script execution.
194
+
It is synchronous and blocks the execution until the timeout is passed.
195
+
_Hint:_ the popular `setTimeout()` is not available in a Script Task.
195
196
196
-
**OPEN TODO:** The `wait`function returns an integer: it returns `1` if the process was paused (externally by the MS) during the process execution. Else it returns `0`.
197
+
If the _entire process_ is paused from the Management System, all script code is also paused until the process is resumed.
198
+
If a _pause_ occurs during a `wait()`, the system stores the original expiration time of `wait()`.
199
+
If the process resumes before this original expiration time, the script waits for the remaining time before continuing with the next instructions.
200
+
If the original expiration time has passed after the process resumes, it immediately continues with the next instructions after `wait()`.
201
+
202
+
{/* -> uncomment when Bug is solved
203
+
**OPEN Bug:** The `wait`function returns an integer: it returns `1` if the process was paused (externally by the MS) during the process execution. Else it returns `0`.
197
204
This information is useful since a pausing of the process has an undefined timespan, so the defined _waiting_ time is not reliable anymore.
|`wait(<number in milliseconds>)`|timeout for pausing the the Script Task execution |
209
+
|`wait(<milliseconds: number>)`|`milliseconds` for pausing the the Script Task execution |
202
210
203
211
**Example Code**
204
212
213
+
```js
214
+
// log with time:
215
+
log.info("Before wait()");
216
+
wait(10000); // 10s
217
+
log.info("After wait()");
218
+
```
219
+
220
+
{/* -> uncomment when Bug is solved
205
221
```js
206
222
let hasBeenPaused = wait(10000);
207
223
if (hasBeenPaused) {
@@ -212,6 +228,29 @@ if (hasBeenPaused) {
212
228
log.info('sucessfully waited ');
213
229
}
214
230
```
231
+
*/}
232
+
233
+
### `waitAsync( <ms> ): Promise`[#wait]
234
+
235
+
<Callouttype='warning'>
236
+
The use of `waitAsync( <ms> ): Promise` is only suitable for advanced users.
237
+
It makes code execution asynchronous.
238
+
This allows you to achieve multiple semi-parallel code executions.
239
+
</Callout>
240
+
241
+
Like [`wait()`](#wait) but asynchronous, so it immediately continues with the next code instructions and does not block the specified timeout is finished.
242
+
In this sense, it is similar to the usual `setTimeout()` but only with a Promise. So, you can use `await` or `then()`.
|`waitAsync(<milliseconds: number>): Promise`|`milliseconds` for pausing the the Script Task execution. Returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). |
0 commit comments