# Synchronous vs. Asynchronous

When integrating systems or executing backend logic, ONEWEB supports both **synchronous** and **asynchronous** execution models.\
Understanding the difference between these two approaches is essential for designing **efficient, scalable, and user‑friendly integrations**.

***

### Synchronous Execution

A **synchronous operation** is a **blocking execution** model.

* The caller waits until the operation finishes
* The execution flow does not continue until a response is returned
* The user or calling component cannot proceed while the operation is in progress

#### Characteristics

* Blocking: execution waits for completion
* Immediate response required
* Suitable for short‑running operations

#### Typical Use Cases

* Immediate data validation
* Real‑time data retrieval
* Backend service calls that must return a result before continuing

In ONEWEB, synchronous execution is commonly used when:

* A **Microflow** must return data immediately
* UI behavior depends directly on the response

***

### Asynchronous Execution

An **asynchronous operation** is a **non‑blocking execution** model.

* The caller initiates the operation and continues execution
* The operation runs in the background
* Results may be handled later or via a callback/update

This model allows greater **parallelism and responsiveness**, especially in long‑running operations.

#### Characteristics

* Non‑blocking
* Caller does not wait for completion
* Supports background processing

#### Typical Use Cases

* Long‑running business logic
* Background computation
* Workflow initiation
* Integration with external systems that may take time to respond

***

### Asynchronous Nature of Process Flow

A **Process Flow** in ONEWEB is inherently **asynchronous by design**.

* Submitting a process (for example, via a Process Button) **initiates** the business process
* The UI or calling component **does not wait** for the process to finish
* This is intentional, as:
  * Processes may span **hours, days, or even weeks**
  * Waiting for completion would be impractical and inefficient

Process Flow is therefore best suited for:

* Approval workflows
* Multi‑step business operations
* Integrations involving human intervention or long‑running orchestration

***

### Flexible Execution in Microflow

Unlike Process Flow, **Microflow** can be designed to run **either synchronously or asynchronously**, depending on the integration requirement.

#### Synchronous Microflow

* The caller waits for the Microflow to complete
* Used when immediate results are required
* Common in UI‑to‑backend interactions

#### Asynchronous Microflow

* The Microflow is triggered in the background
* The user can continue interacting with the UI
* Results can later update the screen or system state

ONEWEB provides a **screen‑blocking option** when invoking Microflows:

* **Screen blocking enabled → synchronous behavior**
* **Screen blocking disabled → asynchronous behavior**

This gives developers fine‑grained control over user experience and execution flow.

***

### Choosing Between Synchronous and Asynchronous

| Scenario                               | Recommended Model           |
| -------------------------------------- | --------------------------- |
| Immediate response required            | Synchronous                 |
| Background processing                  | Asynchronous                |
| Long‑running workflow                  | Asynchronous (Process Flow) |
| UI‑dependent backend call              | Synchronous Microflow       |
| Integration with slow external systems | Asynchronous                |

Choosing the correct execution model improves:

* Application responsiveness
* User experience
* System scalability

***

### Summary

ONEWEB supports both **synchronous** and **asynchronous** execution models to accommodate different integration and workflow requirements.

* **Process Flow** is primarily asynchronous and designed for long‑running workflows
* **Microflow** supports both synchronous and asynchronous execution, controlled by configuration
* Choosing the appropriate model ensures efficient execution, better performance, and optimal user experience

Understanding when and how to use each execution model is a key part of designing **robust integrations** in ONEWEB.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.onewebstack.com/oneweb-platform-th/building-apps/integrations/develop-integration-with-oneweb-microflow/synchronous-vs.-asynchronous.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
