docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method ToAwaitable

    ToAwaitable()

    Creates an Awaitable that completes when the operation completes.

    Declaration
    public Awaitable ToAwaitable()
    Returns
    Type Description
    Awaitable

    An awaitable that completes when the operation completes, or throws on failure.

    Remarks

    On failure, throws an AsyncOperationHandleException whose Handle carries a reference you must release (via e.Handle.Release()). The returned Awaitable can only be awaited once.

    ToAwaitable(CancellationToken)

    Creates an Awaitable that completes when the operation completes, or is canceled when cancellationToken is canceled. See the generic ToAwaitable(CancellationToken) overload for details.

    Declaration
    public Awaitable ToAwaitable(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    Token that cancels the awaitable and releases this handle.

    Returns
    Type Description
    Awaitable

    An awaitable that completes when the operation completes, or throws on failure or cancellation.

    ToAwaitable(MonoBehaviour)

    Creates an Awaitable tied to owner's destruction - shorthand for ToAwaitable(owner.destroyCancellationToken). See the generic ToAwaitable(MonoBehaviour) overload for the Destroy-vs-Disable scoping caveat.

    Declaration
    public Awaitable ToAwaitable(MonoBehaviour owner)
    Parameters
    Type Name Description
    MonoBehaviour owner

    The component whose destruction cancels the awaitable and releases this handle.

    Returns
    Type Description
    Awaitable

    An awaitable that completes when the operation completes, or throws on failure or cancellation.

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)