# Awaitable

> Custom Unity type that can be awaited and used as an async return type in the C# asynchronous programming model.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule
* **Implements:** [IEnumerator](https://learn.microsoft.com/dotnet/api/system.collections.ienumerator)

```csharp
public class Awaitable : IEnumerator
```

## Remarks

`Awaitable` is usually a preferable alternative to .NET `Task` for asynchronous code in Unity. It's important, however, to know the differences between the two. Most notably, instances of the `Awaitable` class are pooled and therefore not safe to `await` multiple times in the same method.

For more information, refer to [Asynchronous programming with the Awaitable class](/engine/6000.7/manual/scripting/optimization/async-await-support.md) in the Manual.

## Examples

```csharp
private async Awaitable DoSomethingAsync()
{
   await LoadSceneAsync("SomeScene");
   await SomeApiReturningATask();
   await Awaitable.NextFrameAsync();
   // <...>
}
```

## Properties

| Property                                                                            | Description                                       |
| ----------------------------------------------------------------------------------- | ------------------------------------------------- |
| [IsCompleted](/engine/6000.7/script-reference/unityengine/awaitable/iscompleted.md) | Indicates if the awaitable has run to completion. |

## Methods

| Method                                                                                                    | Description                                                                                                         |
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| [Cancel](/engine/6000.7/script-reference/unityengine/awaitable/cancel.md)                                 | Cancels the awaitable. If the awaitable is being awaited, the awaiter receives a System.OperationCanceledException. |
| [LogExceptionsAndForget](/engine/6000.7/script-reference/unityengine/awaitable/logexceptionsandforget.md) | Configures the async method to log exceptions without an explicit result check.                                     |

## Static Methods

| Method                                                                                                  | Description                                                                                                                   |
| ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| [BackgroundThreadAsync](/engine/6000.7/script-reference/unityengine/awaitable/backgroundthreadasync.md) | Resumes execution on a ThreadPool background thread. Completes immediately when called from a background thread.              |
| [EndOfFrameAsync](/engine/6000.7/script-reference/unityengine/awaitable/endofframeasync.md)             | Resumes execution after all Unity subsystems have run for the current frame.                                                  |
| [FixedUpdateAsync](/engine/6000.7/script-reference/unityengine/awaitable/fixedupdateasync.md)           | Resumes execution on the next fixed update frame.                                                                             |
| [FromAsyncOperation](/engine/6000.7/script-reference/unityengine/awaitable/fromasyncoperation.md)       | Creates an Awaitable from an existing [AsyncOperation](/engine/6000.7/script-reference/unityengine/asyncoperation.md) object. |
| [MainThreadAsync](/engine/6000.7/script-reference/unityengine/awaitable/mainthreadasync.md)             | Resumes execution on the Unity main thread. Completes immediately when called from the main thread.                           |
| [NextFrameAsync](/engine/6000.7/script-reference/unityengine/awaitable/nextframeasync.md)               | Resumes execution on the next frame.                                                                                          |
| [WaitForSecondsAsync](/engine/6000.7/script-reference/unityengine/awaitable/waitforsecondsasync.md)     | Resumes execution after the specified number of seconds.                                                                      |
