Example #1
0
        public static async IAsyncEnumerable <TResult> ExecuteForAllEventsAsync <TResult>(this IEventProvider eventProvider, Func <EventOptions, Task <TResult> > executer, [EnumeratorCancellation] CancellationToken cancellationToken = default)
        {
            foreach (var info in eventProvider.Where(p => p.ConsumerType != null))
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                }

                yield return(await executer.Invoke(info));
            }
        }