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
3 answers

Dispose a disposable, instantiated within a non-async IAsyncEnumerable, after enumeration

I want to expose reading and parsing data from a file asynchronously into strings, through an IAsyncEnumerable, so my calling code can process the data as it comes in. The problem is that I have to pass a disposable (here modeled by a…
CodeCaster
  • 147,647
  • 23
  • 218
  • 272
0
votes
2 answers

Convert IEnumerable> into an IAsyncEnumerable

Suppose a have a variable that is an IEnumerable>. How to convert to an IAsyncEnumerable ?? I tried some link methods, but could not do it!
0
votes
1 answer

Combine AsyncEnumerable with SelectMany (synchronous?)

I try to use an AsyncEnumerable that returns a list of items in each yield and try to use SelectMany (or SelectManyAsync) to retrieve all items. Working sample: IAsyncEnumerable> source = ...; await foreach (var list in source) { …
Sebastian Schumann
  • 3,204
  • 19
  • 37
0
votes
2 answers

Tasks not running concurrently by custom LINQ operator

I am attempting to create a concurrent version of SelectAwait (and others) present as part of System.Linq.Async which provides extension methods to IAsyncEnumerable. This is the code that I am using: private async IAsyncEnumerable
Grimson
  • 540
  • 1
  • 5
  • 21
0
votes
1 answer

How to unit test method with IAsyncEnumerable return type

I have a method: public async IAsyncEnumerable Query(string name) { if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Name is missing", nameof(name)); await foreach(var item in…
Dušan
  • 269
  • 1
  • 11
0
votes
0 answers

In ASP.NET core 6 can I control how IAsyncEnumerable is formatted in the response?

I am writing a controller that returns lines of text from a file, and I want to stream them using IAsyncEnumerable. If I do that, all the strings are returned in the response in a single line of text - this is not particularly friendly to the…
Aaron Whittier
  • 233
  • 1
  • 2
  • 8
0
votes
2 answers

await IAsyncEnumerable where is it used?

It says here: Starting with C# 8.0, IAsyncEnumerable, for an async method that returns an async stream. Question. In addition to the specified example with foreach, is it possible to use more the await with IAsyncEnumerable somehow, or is…
user19747379
0
votes
2 answers

How to iterate dictionary in "await foreach"

Help with a small problem... I have a method that returns a dictionary. I need to rewrite it in such a way that I can enumerate the result of this method using await foreach. Please help me, something is not working for me at all. It's my…
itehnoviking
  • 19
  • 1
  • 6
0
votes
1 answer

Checking throws exception in IAsyncEnumerable method - xUnit

I have an async method lik this: public async IAsyncEnumerable> Load() { //some times throws exception in this line var responseEnumerable = _crawler.Crawl(); await foreach (var response in…
Hamidreza Samadi
  • 637
  • 1
  • 7
  • 24
0
votes
0 answers

ASP.NET Core use IAsyncEnumerate as input parameter

In an ASP.NET Core WebApi Application I succesfully used IAsyncEnumerable as return type by the controller. Now I'd like to know if(and how) i can use IAsyncEnumerable as input parameter. Something like this…
GLuca74
  • 105
  • 6
0
votes
1 answer

Writing and reading to/from gRPC full duplex channel in .NET simultaneously using async enumerables

I have a client-server scenario with a pipeline fully implemented with gRPC duplex streams. The pipeline is initiated by the client. At every step (duplex call) the client reads items from an IAsyncEnumerable and writes them on the channel. The…
Daniel Leiszen
  • 1,827
  • 20
  • 39
0
votes
2 answers

IAsyncEnumerable and throttling

Is it possible to throttle the data when consuming IAsyncEnumerable? I have a stream of data coming in rapidly, and I'm only interested in the last element every N seconds. Thanks.
Alec Bryte
  • 580
  • 1
  • 6
  • 18
0
votes
1 answer

How to batch a ChannelReader, enforcing a maximum interval policy between consuming and processing any individual item?

I am using a Channel in a producer-consumer scenario, and I have the requirement to consume the channel in batches of 10 items each, and without letting any consumed item to stay idle in a buffer for more than 5 seconds. This duration is the…
0
votes
1 answer

Why does async IO block in C#?

I've created a WPF app that targets a local document database for fun/practice. The idea is the document for an entity is a .json file that lives on disk and folders act as collections. In this implementation, I have a bunch of .json documents that…
eriyg
  • 99
  • 1
  • 12
0
votes
3 answers

IAsyncEnumerable like a Source for akka streams

I want to use IAsyncEnumerable like a Source for akka streams. But I not found, how do it. No sutiable method in Source class for this code. using System.Collections.Generic; using System.Threading.Tasks; using Akka.Streams.Dsl; namespace…
Dmitry
  • 1
  • 1
1 2 3
10
11