private void _UpdateCloudAnchorRequest(CloudAnchorRequest request, bool isNewRequest = false)
        {
            var cloudState = request.NativeSession.AnchorApi.GetCloudAnchorState(request.AnchorHandle);

            if (cloudState == ApiCloudAnchorState.Success)
            {
                var result = new CloudAnchorResult()
                {
                    Response = CloudServiceResponse.Success,
                    Anchor   = XPAnchor.Factory(request.NativeSession, request.AnchorHandle)
                };

                request.OnTaskComplete(result);
                request.IsComplete = true;
            }
            else if (cloudState != ApiCloudAnchorState.TaskInProgress)
            {
                request.NativeSession.AnchorApi.Detach(request.AnchorHandle);
                request.NativeSession.AnchorApi.Release(request.AnchorHandle);

                var result = new CloudAnchorResult()
                {
                    Response = cloudState.ToCloudServiceResponse(),
                    Anchor   = null
                };

                request.OnTaskComplete(result);
                request.IsComplete = true;
            }
            else if (isNewRequest)
            {
                m_CloudAnchorRequests.Add(request);
            }
        }
        private void UpdateCloudAnchorRequest(
            CloudAnchorRequest request, bool isNewRequest = false)
        {
            var cloudState =
                request.NativeSession.AnchorApi.GetCloudAnchorState(request.AnchorHandle);

            if (cloudState == ApiCloudAnchorState.Success)
            {
                XPAnchor             xpAnchor = null;
                CloudServiceResponse response = CloudServiceResponse.Success;
                try
                {
                    xpAnchor = XPAnchor.Factory(request.NativeSession, request.AnchorHandle);
                }
                catch (Exception e)
                {
                    Debug.LogError("Failed to create XP Anchor: " + e.Message);
                    response = CloudServiceResponse.ErrorInternal;
                }

                var result = new CloudAnchorResult()
                {
                    Response = response,
                    Anchor   = xpAnchor,
                };

                request.OnTaskComplete(result);
                request.IsComplete = true;
            }
            else if (cloudState != ApiCloudAnchorState.TaskInProgress)
            {
                if (request.NativeSession != null && !request.NativeSession.IsDestroyed)
                {
                    request.NativeSession.AnchorApi.Detach(request.AnchorHandle);
                }

                AnchorApi.Release(request.AnchorHandle);

                var result = new CloudAnchorResult()
                {
                    Response = cloudState.ToCloudServiceResponse(),
                    Anchor   = null
                };

                request.OnTaskComplete(result);
                request.IsComplete = true;
            }
            else if (isNewRequest)
            {
                _cloudAnchorRequests.Add(request);
            }
        }