re: C# events as asynchronous streams with ReactiveX or Channels VIEW POST

re: Do you have any practical examples where someone would want to do this?

It's a good question. In theory, I imagine it could be any code that needs to process a sequence of events, e.g., collecting data from an IoT device or processing stock market updates. For use cases like these, we would probably want to use a bounded channel or something like BufferBlock<T> as event buffer on the producer side, to prevent the queue from growing indefinitely.

In practice though, I myself so far only have used that for automated coded UI testing of my side project DevComrade with asynchronous coroutines approach. In that case, the consumer of IAsyncEnumerable stream is essentially a pseudo-linear script (thanks to async/await) that just expects UI events in a particular order. I.e., it doesn't even need an await foreach loop. I'll go into more details about that with another blog post.

Code of Conduct Report abuse