# MessageCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/os/MessageCompat.java+class:androidx.core.os.MessageCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***

<br />

```
class MessageCompat
```

<br />

*** ** * ** ***

Helper for accessing features in `https://developer.android.com/reference/android/os/Message.html`.

## Summary

| ### Public functions |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/os/MessageCompat#isAsynchronous(android.os.Message)(message: https://developer.android.com/reference/android/os/Message.html)` Returns true if the message is asynchronous, meaning that it is not subject to `https://developer.android.com/reference/android/os/Looper.html` synchronization barriers. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/os/MessageCompat#setAsynchronous(android.os.Message,boolean)(message: https://developer.android.com/reference/android/os/Message.html, async: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether the message is asynchronous, meaning that it is not subject to `https://developer.android.com/reference/android/os/Looper.html` synchronization barriers. |

## Public functions

### isAsynchronous

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun isAsynchronous(message: Message): Boolean
```

Returns true if the message is asynchronous, meaning that it is not subject to `https://developer.android.com/reference/android/os/Looper.html` synchronization barriers.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | True if the message is asynchronous. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/os/MessageCompat#setAsynchronous(android.os.Message,boolean)` |   |
| `https://developer.android.com/reference/android/os/Message.html#isAsynchronous()` |   |

### setAsynchronous

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun setAsynchronous(message: Message, async: Boolean): Unit
```

Sets whether the message is asynchronous, meaning that it is not subject to `https://developer.android.com/reference/android/os/Looper.html` synchronization barriers.

Certain operations, such as view invalidation, may introduce synchronization barriers into the `https://developer.android.com/reference/android/os/Looper.html`'s message queue to prevent subsequent messages from being delivered until some condition is met. In the case of view invalidation, messages which are posted after a call to `https://developer.android.com/reference/android/view/View.html#invalidate()` are suspended by means of a synchronization barrier until the next frame is ready to be drawn. The synchronization barrier ensures that the invalidation request is completely handled before resuming.

Asynchronous messages are exempt from synchronization barriers. They typically represent interrupts, input events, and other signals that must be handled independently even while other work has been suspended.

Note that asynchronous messages may be delivered out of order with respect to synchronous messages although they are always delivered in order among themselves. If the relative order of these messages matters then they probably should not be asynchronous in the first place. Use with caution.

| Parameters |
|---|---|
| `message: https://developer.android.com/reference/android/os/Message.html` | message for this to set the mode. |
| `async: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | True if the message is asynchronous. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/os/MessageCompat#isAsynchronous(android.os.Message)` |   |
| `https://developer.android.com/reference/android/os/Message.html#setAsynchronous(boolean)` |   |