コード例 #1
0
            public async IAsyncEnumerable <IQueryResult> ExecuteAsync()
            {
                await using IAsyncEnumerator <object> enumerator =
                                _sourceStream.ReadEventsAsync().GetAsyncEnumerator(
                                    _requestContext.RequestAborted);

                while (await enumerator.MoveNextAsync().ConfigureAwait(false))
                {
                    if (_requestContext.RequestAborted.IsCancellationRequested)
                    {
                        break;
                    }
                    yield return(await OnEvent(enumerator.Current).ConfigureAwait(false));
                }
            }
コード例 #2
0
        public IAsyncEnumerator <IQueryResult> GetAsyncEnumerator(
            CancellationToken cancellationToken = default)
        {
            try
            {
                IAsyncEnumerator <object> eventStreamEnumerator =
                    _sourceStream.ReadEventsAsync()
                    .GetAsyncEnumerator(cancellationToken);

                return(new SubscriptionEnumerator(
                           eventStreamEnumerator,
                           _onEvent,
                           _subscription,
                           _diagnosticEvents,
                           cancellationToken));
            }
            catch (Exception ex)
            {
                _diagnosticEvents.SubscriptionEventError(_subscription, ex);
                return(new ErrorSubscriptionEnumerator());
            }
        }