/// <summary> Gets the participants of a thread asynchronously. </summary> /// <param name="skip"> Skips participants up to a specified position in response. </param> /// <param name="cancellationToken"> The cancellation token to use. </param> /// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception> public virtual AsyncPageable <ChatParticipant> GetParticipantsAsync(int?skip = null, CancellationToken cancellationToken = default) { async Task <Page <ChatParticipant> > FirstPageFunc(int?pageSizeHint) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ChatThreadClient)}.{nameof(GetParticipants)}"); scope.Start(); try { Response <ChatParticipantsCollection> response = await _chatThreadRestClient.ListChatParticipantsAsync(Id, pageSizeHint, skip, cancellationToken).ConfigureAwait(false); return(Page.FromValues(response.Value.Value.Select(x => new ChatParticipant(x)), response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } async Task <Page <ChatParticipant> > NextPageFunc(string nextLink, int?pageSizeHint) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ChatThreadClient)}.{nameof(GetParticipants)}"); scope.Start(); try { Response <ChatParticipantsCollection> response = await _chatThreadRestClient.ListChatParticipantsNextPageAsync(nextLink, Id, pageSizeHint, skip, cancellationToken).ConfigureAwait(false); return(Page.FromValues(response.Value.Value.Select(x => new ChatParticipant(x)), response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc)); }