Cancel async method

Command group Flag affected Reversible Execute on client Platform(s)
Methods YES NO NO All

Syntax

Cancel async method {id-to-cancel (return-value-from-do-async-method)}

Description

This command allows you to cancel the execution of a method that is executing as a result of a call to the Do async method command.

This command takes a single parameter id-to-cancel, which is the asynchronous call id returned by Do async method.

This command sets the flag if it has marked the async method for cancellation. Omnis only checks to see if the method is marked for cancellation after the completion of each method command, so cancellation may not occur immediately. Also, if you are executing a sensitive block of code, which should not be cancelled in this way, you can use the Begin critical block and End critical block commands around the sensitive code. Omnis will only cancel the method execution when the thread ends the critical block. If the flag is cleared, then either the asynchronous call id is invalid, or the method has finished. After successfully cancelling a method call, Omnis still sends the $asynccomplete message, but with an error text parameter that indicates that the call was cancelled.

Note

You can only call Cancel async method when running in the normal foreground thread.

Example

# iCallId was returned by Do async method
Cancel async method {iCallId}