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
1
vote
1 answer

System.Threading.Channels ReadAsync() method is blocking execution

Overview I am attempting to write an IAsyncEnumerable wrapper around an IObserver interface. At first I used a BufferBlock as the backing data store, but I found out through performance testing and research that it is actually a pretty slow…
1
vote
2 answers

Why does my IAsyncEnumerable call in EF Core not enumerate asynchronously?

I am writing a C# method that streams a large number of rows from a SQL query (not a straight DBSet!), performs some transformation on them, then writes the results into a MongoDB database. I am trying to make this run as quickly as possible, and…
1
vote
0 answers

creating mock setup for IAsyncEnumerable in C# using moq

I am trying to test QueryAllScheduledJob method. It contains a call to GetScheduledJobs which return an IAsyncEnumerable collection. I have created a setup for GetScheduledJobs. I am getting an exception of type 'null instance' for GetScheduledJobs.…
maxspan
  • 13,326
  • 15
  • 75
  • 104
1
vote
2 answers

Build an IAsyncEnumerable using TaskCompletionSource

I have a method that accepts an IEnumerable and returns it transformed using the yield operator. To transform one element of the enumerable, I need to first know the value of another element. Therefore, I thought of using a TaskCompletionSource to…
1
vote
2 answers

How to resolve lists of IAsyncEnumerables as soon as a item is ready

public async IAsyncEnumerable FindByIds(List ids) { List> splitIdsList = ids.Split(5); var entityList = splitIdsList.Select(x => FindByIdsQuery(x)).ToList(); foreach (var entities in…
user2687506
  • 789
  • 6
  • 21
1
vote
1 answer

How to use SqlBulkCopy to write an IAsyncEnumerable

I have the following method that returns an IAsyncEnumerable: async IAsyncEnumerable RunReport() { var handler = new HttpClientHandler(); var client = new HttpClient(handler); client.BaseAddress = new Uri(""); …
priehl
  • 644
  • 2
  • 9
  • 21
1
vote
2 answers

Why doesn't my function await the end of ForEachAsync?

I'm trying to fill my model with data that I get from an asynchronous operation to my database. The problem is that the function returns the View (without the completed model), despite my await call. I have tried to put a timer (I know that is not…
djohnson
  • 15
  • 4
1
vote
0 answers

IAsyncEnumerable with SqlDataReader and cancellation token hangs on cancel

I was trying to test out the new IAsyncEnumerable feature in c# 8(as well as the .NET Core 3 WinForm preview) but everything seems to bind up when I try to cancel the task. Pausing the debugger on the reader.ReadAsync while loop then continuing…
Marie
  • 2,114
  • 1
  • 17
  • 31
0
votes
0 answers

C# OneOf package and returning of IAsyncEnumerable

I am playing around with OneOf (https://github.com/mcintyre321/OneOf) nuget package, but I was wondering can I use it with IAsyncEnumerable operations so I camu up sith this little monster: private async Task,…
Wojciech Szabowicz
  • 3,646
  • 5
  • 43
  • 87
0
votes
2 answers

What to name a stream that "only streams once"

Assume I have a method that performs some I/O operation that asynchronously returns data as some type implementing IAsyncEnumerable example: class MyDataStream: IAsyncEnumerable { //Code omitted for brevity } class Bla { MyDataStream…
Ar Es
  • 389
  • 3
  • 12
0
votes
1 answer

JsonSerializer.DeserializeAsyncEnumerable async processing and torn JSON stream behaviour

Having had to solve the problem of iterating through the YEILDed results from a C# IAsyncEnumerable controller method myself with Javascript, by writing my own iterator to handle JSON tears, I was extolling the virtues of the C#…
0
votes
1 answer

Using FakeItEasy to fake an AsyncPageable

I've run into a problem while testing an Azure Function which runs on top of Azure Tables: How can I fake the result of a table query which returns an AsyncPageable? Here's the code under test... public async Task GetProjectByIdAsync(Guid…
awj
  • 7,482
  • 10
  • 66
  • 120
0
votes
1 answer

IAsyncEnumerable chunk-size throttle(s) and format conventions for HttpResponse JSON

I have observed that if I increase the interval between my .NET C# Controller method Yields like: - await Task.Delay(100); // Slow down the Demo That each server yield corresponds 1:1 to a Javascript: - response.body.getReader() read() But at…
McMurphy
  • 1,235
  • 1
  • 15
  • 39
0
votes
1 answer

Firefox triggers Websocket error from IAsyncEnumerable Core MVC controller method

I am using a cancellable Javascript Fetch to retrieve a C# Microsoft.AspNet.WebApi.Core IAsyncEnumerable Controller method. There is no error with Chrome or Edge but Firefox logs the following: - I don't know if it is a W3C standard to convert a…
McMurphy
  • 1,235
  • 1
  • 15
  • 39
0
votes
0 answers

IAsyncEnumerable converted to IObservable (and Task) doesn't start

I have the following code in my BackgroundService: public async Task ExecuteAsync(CancellationToken cancellationToken) { await GetElements(cancellationToken) .ToObservable() .Buffer(TimeSpan.FromMinutes(1), 100) …
mnj
  • 2,539
  • 3
  • 29
  • 58