Wait for External Event Async
The Wait for External Event Async construct in allows a workflow to pause execution asynchronously until a specific event is received via the Raise Event mechanism. Unlike the synchronous version, this allows the workflow to continue execution until it reaches an await step on the activity.
How It Works
Use Wait for External Event either in an assignment or within WhenAny, WhenAll constructs to properly receive and process the data.
- Workflow execution continues until an await step is encountered.
- The workflow pauses at the await step and waits for an external event.
- An external system triggers the event, providing the required data.
- The workflow captures and processes the event data.
- The workflow resumes execution and performs actions such as, triggering tasks, or making decisions based on the received input.
The workflow can be configured to handle different event outcomes dynamically, defining specific rules or logic to process varying conditions.
| Property | Description | Comments |
|---|---|---|
| Label | A label for identifying the event. | Used for easy reference. |
| Event Name* | The name of the event that the workflow is waiting for to resume execution. | |
| Input Type* | Specifies the type of data expected. | Helps validate incoming data. |
| Activity Handle* | Unique identifier required for Asynchronous execution. | This will be awaited when required. Activity Handle is used to track and manage asynchronous activities. Since asynchronous operations do not return responses immediately, the Activity Handle acts as a reference to monitor the execution and retrieve results when available |
| Comment | Specify whether to comment this construct or not. Either Yes or No. | If marked as Yes, the construct is treated as a commented expression and ignored in code generation. |
| Description | Explains the purpose and impact of the event. | Helps in workflow design and understanding. |
'Note: ' + ($args[0].Groups[1].Value -replace '\r?\n', ' ')
Edge Paths
Double-click on the edge path to configure the properties as required and then click Save.
| Property | Description | Comments |
|---|---|---|
| Type | Select type of the edge path. Choose one of below: expression default after | Expression field is visible only when the selected Type ‘expression’. expression: expression is the value or variable that is evaluated and compared against different case values. “Wait for external event async” construct allows user to create multiple edge paths of type ‘expression’ as cases. The execution flow depends on whether the expression matches one of the predefined cases. default: when no matching case is found for the given expression. It serves as a fallback option. after: Used to specify the logic run outside the Wait for External Event. |
Example Use Case
Scenario: Asynchronous Order Processing
In an e-commerce application, after an order is placed, the workflow waits for payment confirmation before proceeding with order fulfillment.
Workflow Steps:
- Step 1: Customer places an order.
- Step 2: The workflow continues processing other steps (e.g., generating an order ID, sending confirmation email).
- Step 3: The workflow reaches the Wait for External Event Async step and pauses execution at the await point.
- Step 4: The payment gateway sends a Raise Event when payment is successful.
- Step 5: The workflow resumes execution and moves to order fulfillment.