# 使用 Awaitable 类进行异步编程

> Asynchronous programming in Unity with the .NET async and await keywords and Unity's own custom Awaitable class.

异步编程允许您的代码执行长时间运行的任务，而不会阻塞主线程。这使应用程序能够在等待异步任务完成时保持响应并执行其他任务。

Unity 支持使用 .NET [异步](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/async)关键字和 [await](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/await) 运算符的简化异步编程模型。

在阅读有关 Unity 中的异步编程的信息之前，请确保了解 .NET 中的异步编程的基本元素。有关重要上下文，请参阅[使用 async 和 await 的异步编程](https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/)以及[ Task 异步编程模型](https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/task-asynchronous-programming-model)。

| **主题**                                                                                                               | **描述**                                                        |
| -------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| [Awaitable 简介](/engine/6000.0/manual/scripting/optimization/async-await-support/async-awaitable-introduction.md)     | 了解 Unity 的 `Awaitable` 的主要特性，以及相比于 .NET `Task` 和基于迭代器的协程有何不同。 |
| [Awaitable 完成和延续](/engine/6000.0/manual/scripting/optimization/async-await-support/async-awaitable-continuations.md) | 了解异步代码如何在等待的任务完成后恢复，以及这对应用程序的功能和性能有何影响。                       |
| [Awaitable 代码示例参考](/engine/6000.0/manual/scripting/optimization/async-await-support/async-awaitable-examples.md)     | 参考 `Awaitable` 代码示例解决常见的异步编程问题。                               |

## 其他资源##additional-resources

* [Awaitable API 参考](/engine/6000.0/script-reference/unity-engine/awaitable.md)
* [C# 作业系统](/engine/6000.0/manual/scripting/optimization/job-system.md)
* [协程](/engine/6000.0/manual/scripting/object-oriented-development/coroutines.md)
