Cancel Token Source
Verb: cancelToken
Cancels the continuous action of a command associated to a cancel token.
Syntax
cancelToken --token(CancellationTokenSource)
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--token | Cancel token source | Required | Cancellation Token Source | Cancel Token, returned by continuous execution commands, used to manage which command should be canceled. |
Example
Wait for a Notepad window identified by regular expression. Each time the Launch and Attach Window command opens a Notepad window, the Watch and Close Window command closes the window automatically. Using the cancel token stored in the token parameter, the Cancel Token Source command cancels the continuous action and the Notepad window is no longer closed automatically.
defVar --name windowNotepad --type Window
defVar --name token --type CancellationTokenSource
watchAndCloseWindow --useregex --regexPattern Notepad --regexOptions "IgnoreCase" --processname notepad --recursive token=value
launchWindow --executablepath "C:\\Windows\\notepad.exe" windowNotepad=value
launchWindow --executablepath "C:\\Windows\\notepad.exe" windowNotepad=value
cancelToken --token ${token}
launchWindow --executablepath "C:\\Windows\\notepad.exe" windowNotepad=value
//watchAndCloseWindow automatically closes new Notepad windows.
//After canceling the continuous action with the Cancel Token Source command, new Notepad windows are no longer closed.
Remarks
Some continuous execution commands, such as Watch and Close Window and Watch and Set Credentials in Browser, return a cancellation token, which can be used by the Cancel Token Source command to cancel such continuous action in the process in which it is set.