简体   繁体   中英

Equivalent of .onBackpressureBuffer() in Rx.Net?

There's a source that emits items asynchronously, in my case in the order of 10 items withing some seconds.

  • I want to handle all of them.
  • In order of appearance
  • One at a time
  • Handling of each might take long (like 1-5 seconds)
  • There might be new items while one is being handled

At the moment I'm porting a Java app to C#. In the RxJava world there's the onBackpressureBuffer method, whereas in Rx.Net there are a bunch of different ones and cannot figure out the equivalent.

I guess I could use Buffer() with a zero delay and use the produced enumerable, but seems to be hacky.

edit: please read comments before voting negatively

Rx.NET doesn't support backpressure and it can't the way RxJava does: one has to design the protocol so that there is a request channel between a producer and its consumer. In concept, Async Enumerables can get you backpressure in the form of 1-by-1 item delivery (called async pull, promise per item, continuations, etc. in some cases).

There is a C# library that matches the features of the RxJava Flowable type relatively well (but not 100%): Reactive4.NET that can also interop with IObservable and thus with Rx.NET if needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM