Questions tagged [iasyncenumerable]

IAsyncEnumerable exposes an IAsyncEnumerator enumerator that provides asynchronous iteration over values of type T

IAsyncEnumerable<T> was introduced as part of asynchronous streams in C# 8, which allows to retrieve and generate elements asynchronously. You can consume an async stream using an await foreach loop in the same way as you consume any sequence using a foreach loop

163 questions
0
votes
1 answer

Combining IAsyncEnumerator and executing them asynchronously

The first function is designed to enable linq to execute lambda functions safely in parallel (even the async void ones). So you can do collection.AsParallel().ForAllASync(async x => await x.Action). The second function is designed to enable you to…
0
votes
1 answer

IAsyncEnumerator.Current returns null when enumerators collection is not casted to a List

The first function is designed to enable linq to execute lambda functions safely in parallel (even the async void ones). So you can do collection.AsParallel().ForAllASync(async x => await x.Action). The second function is designed to enable you to…
0
votes
0 answers

What happens to the WHERE clause with IAsyncEnumerable in Entity Framework Core?

I'm porting an existing application that uses Entity Framework with a SQL Server database from .NET Framework to .NET Core. In EF6, you could do: private async Task> GetByExpressionAsync(Expression> where)) { return…
howcheng
  • 2,211
  • 2
  • 17
  • 24
0
votes
1 answer

Looking for a better pattern for a visitor-IAsyncEnumerable?

Consider this snippet (much simplified than the original code): async IAsyncEnumerable<(DateTime, double)> GetSamplesAsync() { // ... var cbpool = new CallbackPool( HandleBool: (dt, b) => { }, …
Mario Vernari
  • 6,649
  • 1
  • 32
  • 44
0
votes
0 answers

C# 7.3 IAsyncEnumerator state of the object is invalid

I am trying to produce a stable IAsyncEnumerator for a collection. I am using C# 7.3 and the frameworks I am targeting are .Net Standard 2.1 and .Net Standard 2.0. The enumerator is stable only when I debug. I essentially grab a list of objects 4 in…
0
votes
1 answer

Async Tasks Seem to Run Synchronously

Within Run, I'm trying to queue 10,000 tasks. (This is just an experiment so I can better understand async await.) But the first loop takes over three seconds to complete. I would expect this to be faster since I'm just trying to queue the tasks…
user1325179
  • 1,535
  • 2
  • 19
  • 29
0
votes
1 answer

Why does this ParallelForEachAsync method never return?

I try to execute this code async and parallel by using the ParallelForEachAsync method from this project: Dasync/AsyncEnumerable. Unfortunately the method never returns. The SampleProduct is a simple DTO which has a boolean property and two string…
-1
votes
2 answers

Calling IAsyncEnumerable inside constructor

I have the code below, that is causing me a DeadLock. In the code, i need to call a Database to fill a List inside a constructor. The database call returns an IAsyncEnumerable. public class DatabaseRegistries { public List List {get;} …
-1
votes
1 answer

How GroupBy works with IAsyncEnumerable?

I've implemented IAsyncEnumerable to my HttpClient requests where there is a pagination but I also need to GroupBy them. So I've implemented code like below; public class Item { public int Id {get; set;} public string Name {get;…
sercanD
  • 187
  • 1
  • 13
-1
votes
1 answer

Why does observable not produce any element

I am wondering why my Observable does not produce any element when i am not awaiting its source which is an IAsyncEnumerable.I am using a Select over the Observable, and nothing comes out of it , my code does not execute. public async…
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
-1
votes
2 answers

How to batch an IAsyncEnumerable, enforcing a maximum interval policy between consecutive batches?

I have an asynchronous sequence (stream) of messages that are arriving sometimes numerously and sometimes sporadically, and I would like to process them in batches of 10 messages per batch. I also want to enforce an upper limit to the latency…
Theodor Zoulias
  • 34,835
  • 7
  • 69
  • 104
-1
votes
1 answer

await foreach blocks execution

I'm learning EFCore and IAsyncEnumerable (now with .net 5 and all the expectation) and I'm struggling understanding await foreach because in one test case I made is blocking execution (or that seems to me) static async Task Main() { await…
-1
votes
1 answer

Task.WhenAll on List behaving differently than Task.WhenAll on IEnumerable

I'm seeing some odd behavioral differences when calling Task.WhenAll(IEnumerable>) and calling Task.WhenAll(List>) while trying to catch exceptions My code is as follows: public async Task Run() { var en = GetResources(new…
istrupin
  • 1,423
  • 16
  • 32
1 2 3
10
11