The User Cancel Behavior action (highlighted in the screenshot below) enables you to override a user cancellation action and continue with action execution. The following options are available:
•Cancel all actions: If the user presses the Back button (or the Cancel button that appears during the execution of long actions), the cancellation is allowed. This is the default behavior.
•Request cancellation: This option enables you to override a user cancellation action. See the example in the screenshot below. If the user attempts to cancel action execution, the action execution is not interrupted. Instead, the mt-user-tried-to-cancel-actions function is set to true. You can then define a set of appropriate action/s to take depending on the value of this function. After the action's Request cancellation flag has been set to true, the flag can be reset by using the User Cancel Behavior action again, this time with the option set to Cancel all actions. This resets the mt-user-tried-to-cancel-actions function to its default value of false.
In the example shown in the screenshot above, the following is defined for the On Timer Refresh event option:
1.The User Cancel Behavior action is set to Request cancellation. Consequently, if the user presses either the Back or Cancel button, the mt-user-tried-to-cancel-actions function will be set to true.
2.A Loop action is started. With each iteration, successive //City elements are updated, via SOAP requests, with the current time of that city. If there are several //City elements and the updates are taking too long, then the end user might try to cancel the updates by pressing either the Back or Cancel button.
3.At the end of the iteration during which the end user tries to cancel, the mt-user-tried-to-cancel-actions function is evaluated. Since its value at this point will be true (see Point 1 above), a message box is displayed that asks the user whether to go ahead with a cancellation or not. According to the response, the action is either canceled or continued.
4.After the loop is completed, the User Cancel Behavior action is explicitly set to its default value of Cancel all actions. This step is required if you want to set the user-cancellation behavior back to its default (of canceling without requiring confirmation). Otherwise the User Cancel Behavior action will continue to have a value of Request cancellation for all subsequent actions—till it is explicitly changed.