PromiseState.Pending - The operation is still pending. The result of the operation isn't available yet.
PromiseState.Done - The operation is complete, and a result is available.
PromiseState.Cancelled - The operation has been cancelled.
An InterruptiblePromise starts in the PromiseState.Pending state and transitions to PromiseState.Done upon completion. If the Promise is cancelled using InterruptiblePromise.Cancel(), then its state may become PromiseState.Cancelled (see cancelling a Promise for caveats).
Obtaining results from a Promise
There are two ways of obtaining results from an InterruptiblePromise:
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.}
Cancelling a Promise
You can try to cancel an InterruptiblePromise by calling InterruptiblePromise.Cancel(). Due to multi-threading, it is possible that the cancel operation is not successful, and any Unity coroutine may successfully resume execution regardless.
[[["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."],[],[],null,["# InterruptiblePromise< T > Class Reference\n\nInterruptiblePromise\\\u003c T \\\u003e\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-T-#state):\n\n\n- `PromiseState.Pending` - The operation is still pending. The result of the operation isn't available yet.\n- `PromiseState.Done` - The operation is complete, and a result is available.\n- `PromiseState.Cancelled` - The operation has been cancelled.\n\n\u003cbr /\u003e\n\nAn `InterruptiblePromise` starts in the `PromiseState.Pending` state and transitions to `PromiseState.Done` upon completion. If the Promise is cancelled using [InterruptiblePromise.Cancel()](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/Internal/InterruptiblePromise-T-#cancel), then its state may become `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`:\n\n\n#### Polling a Promise\n\n\u003cbr /\u003e\n\nWhen the [InterruptiblePromise](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/Internal/InterruptiblePromise-T-#classGoogle_1_1XR_1_1ARCoreExtensions_1_1Internal_1_1InterruptiblePromise_3_01T_01_4) is created, its [PromiseState](/ar/reference/unity-arf/namespace/Google/XR/ARCoreExtensions#promisestate) is set to `PromiseState.Pending`. You may poll the future using [InterruptiblePromise.State](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/Internal/InterruptiblePromise-T-#state) to query the state of the asynchronous operation. When its state is `PromiseState.Done`, you may obtain the operation's result using [InterruptiblePromise.Result](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/Internal/InterruptiblePromise-T-#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-T-#state) is no longer `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 == 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` by calling [InterruptiblePromise.Cancel()](/ar/reference/unity-arf/class/Google/XR/ARCoreExtensions/Internal/InterruptiblePromise-T-#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."]]