How can I ensure the proper order of event execution when using objects with multiple exit event ports?
When using multiple output event ports to apply logic, the order of the port firing is not guaranteed. For example, consider a component with True, False, and main event ports. You may expect the stack to be unwound when the True or False path has completed, and then fire the main event port. However, the order of the events leaving the block will not necessarily fire in that order. This example automation shows this scenario:
In this example, a control with True/False output event ports was used. However, the concepts in this article also apply to any component with multiple output event ports, such as ListLoop, ForLoop, and Switch.
These kinds of connections also impact code readability. It is difficult to follow logic when it does not flow from beginning to end. Note that connecting logic to the main event port that relies on the True/False execution paths to finish does not guarantee that one did so successfully, just that the thread ended. A final issue to be aware of is that you cannot use an asynchronous link or ParallelProcess component off of a True/False event as the main event port will fire before the downstream True/False or ParallelProcess logic is completed.
Resolution
There a several ways that you can correctly use multiple output event ports. These images show recommended automation examples:
Example 1:
Example 2:
Example 3: