/// <summary>
        /// Gets the final result of the long-running operation asynchronously.
        /// </summary>
        /// <remarks>
        /// Operation must complete successfully (HasValue is true) for it to provide values.
        /// </remarks>
        public override AsyncPageable <AnalyzeBatchActionsResult> GetValuesAsync()
        {
            ValidateOperationStatus();

            async Task <Page <AnalyzeBatchActionsResult> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                //diagnostics scope?
                try
                {
                    Response <AnalyzeJobState> jobState = await _serviceClient.AnalyzeStatusNextPageAsync(nextLink, _showStats).ConfigureAwait(false);

                    AnalyzeBatchActionsResult result = Transforms.ConvertToAnalyzeOperationResult(jobState.Value, _idToIndexMap);
                    return(Page.FromValues(new List <AnalyzeBatchActionsResult>()
                    {
                        result
                    }, jobState.Value.NextLink, jobState.GetRawResponse()));
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(PageableHelpers.CreateAsyncEnumerable(_ => Task.FromResult(_firstPage), NextPageFunc));
        }
Example #2
0
        private AsyncPageable <AnalyzeActionsResult> CreateOperationValueAsync(CancellationToken cancellationToken = default)
        {
            async Task <Page <AnalyzeActionsResult> > NextPageFunc(string nextLink, int?pageSizeHint)
            {
                //diagnostics scope?
                try
                {
                    Response <AnalyzeJobState> jobState = await _serviceClient.AnalyzeStatusNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false);

                    AnalyzeActionsResult result = Transforms.ConvertToAnalyzeActionsResult(jobState.Value, _idToIndexMap);
                    return(Page.FromValues(new List <AnalyzeActionsResult>()
                    {
                        result
                    }, jobState.Value.NextLink, jobState.GetRawResponse()));
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(PageableHelpers.CreateAsyncEnumerable(_ => Task.FromResult(_firstPage), NextPageFunc));
        }