publicvoidCreatePromise(){ResolveAnchorOnRooftopPromiserooftopPromise=AnchorManager.ResolveAnchorOnRooftopAsync(...);StartCoroutine(CheckRooftopPromise(rooftopPromise));}privateIEnumeratorCheckRooftopPromise(ResolveAnchorOnTerrainPromisepromise){yieldreturnpromise;if(promise.State==PromiseState.Cancelled)yieldbreak;varresult=promise.Result;/// Use the result of your promise here.}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-14 UTC."],[[["\u003cp\u003eInterruptiblePromises represent the eventual result of an asynchronous operation and have three states: Pending, Done, and Cancelled.\u003c/p\u003e\n"],["\u003cp\u003eYou can obtain results from an InterruptiblePromise by polling its state or using it within a Unity coroutine with \u003ccode\u003eyield return\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eCalling \u003ccode\u003eCancel()\u003c/code\u003e attempts to stop a pending InterruptiblePromise, although cancellation is not guaranteed due to multi-threading.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eResult\u003c/code\u003e property provides the outcome of the operation when the Promise is in the Done state, while the \u003ccode\u003eState\u003c/code\u003e property indicates the current status of the Promise.\u003c/p\u003e\n"]]],[],null,["# InterruptiblePromise Class Reference\n\nInterruptiblePromise\n====================\n\nPromises represent the eventual completion of an asynchronous operation.\n\nA promise has one of three states, [PromiseState](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate), which can be obtained with [InterruptiblePromise.State](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/Internal/InterruptiblePromise#state):\n\n\n- [PromiseState.Pending](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate_pending) - The operation is still pending. The result of the operation isn't available yet.\n- [PromiseState.Done](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate_done) - The operation is complete, and a result is available.\n- [PromiseState.Cancelled](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate_cancelled) - The operation has been cancelled.\n\n\u003cbr /\u003e\n\nAn [InterruptiblePromise](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/Internal/InterruptiblePromise#classGoogle_1_1XR_1_1ARCoreExtensions_1_1Internal_1_1InterruptiblePromise) starts in the [PromiseState.Pending](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate_pending) state and transitions to [PromiseState.Done](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate_done) upon completion. If the Promise is cancelled using [InterruptiblePromise.Cancel()](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/Internal/InterruptiblePromise#cancel), then its state may become [PromiseState.Cancelled](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate_cancelled) (see [cancelling a Promise](#cancelling-a-promise) for caveats).\n\n\n### Obtaining results from a Promise\n\n\u003cbr /\u003e\n\nThere are two ways of obtaining results from an [InterruptiblePromise](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/Internal/InterruptiblePromise#classGoogle_1_1XR_1_1ARCoreExtensions_1_1Internal_1_1InterruptiblePromise):\n\n\n#### Polling a Promise\n\n\u003cbr /\u003e\n\nWhen the `InterruptiblePromise` is created, its [PromiseState](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate) is set to [PromiseState.Pending](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate_pending). You may poll the future using [InterruptiblePromise.State](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/Internal/InterruptiblePromise#state) to query the state of the asynchronous operation. When its state is [PromiseState.Done](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate_done), you may obtain the operation's result using [InterruptiblePromise.Result](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/Internal/InterruptiblePromise#result).\n\n\n#### Use a Unity Coroutine\n\n\u003cbr /\u003e\n\nPromises use a [`CustomYieldInstruction`](https://docs.unity3d.com/ScriptReference/CustomYieldInstruction.html) to facilitate [Unity coroutines](https://docs.unity3d.com/Manual/Coroutines.html). Use `yield return `**promiseInstance** to pause execution of your coroutine. Unity will resume execution of your coroutine when [InterruptiblePromise.State](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/Internal/InterruptiblePromise#state) is no longer [PromiseState.Pending](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate_pending).\n\n\n\n public void CreatePromise()\n {\n /ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/ResolveAnchorOnRooftopPromise#classGoogle_1_1XR_1_1ARCoreExtensions_1_1ResolveAnchorOnRooftopPromise rooftopPromise =\n AnchorManager.ResolveAnchorOnRooftopAsync(...);\n StartCoroutine(CheckRooftopPromise(rooftopPromise));\n }\n private IEnumerator CheckRooftopPromise(ResolveAnchorOnTerrainPromise promise)\n {\n yield return promise;\n if (promise.State == /ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate_cancelled) yield break;\n var result = promise.Result;\n /// Use the result of your promise here.\n }\n\n\u003cbr /\u003e\n\n\n### Cancelling a Promise\n\n\u003cbr /\u003e\n\nYou can try to cancel an [InterruptiblePromise](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/Internal/InterruptiblePromise#classGoogle_1_1XR_1_1ARCoreExtensions_1_1Internal_1_1InterruptiblePromise) by calling [InterruptiblePromise.Cancel()](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/Internal/InterruptiblePromise#cancel). Due to multi-threading, it is possible that the cancel operation is not successful, and any [Unity coroutine](#use-a-unity-coroutine) may successfully resume execution regardless.\n\n\u003cbr /\u003e\n\n| Details ||\n|---------------------|-------------------------------------------------------------------------------------------|\n| Template Parameters | |-----|------------------------------------| | `T` | The type of the async task result. | |\n\nSummary\n-------\n\n### Inheritance\n\nInherits from: [`UnityEngine::CustomYieldInstruction`](https://docs.unity3d.com/ScriptReference/CustomYieldInstruction.html)\n\n| ### Properties ||\n|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Result](#result) | `T` Gets the result, if the operation is done. |\n| [State](#state) | [PromiseState](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate) Gets the [PromiseState](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate) associated with this promise. |\n\n| ### Public functions ||\n|-----------------------|-----------------------------------------------------------------|\n| [Cancel](#cancel)`()` | `void` Cancels execution of this promise if it's still pending. |\n\nProperties\n----------\n\n### Result\n\n```c#\nT Result\n``` \nGets the result, if the operation is done. \n\n### State\n\n```c#\nPromiseState State\n``` \nGets the [PromiseState](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate) associated with this promise.\n\nUsed to determine if the promise is still waiting for the result.\n\nPublic functions\n----------------\n\n### Cancel\n\n```c#\nvoid Cancel()\n``` \nCancels execution of this promise if it's still pending."]]