Questions tagged [system.reactive]

System.Reactive refers to the Reactive Extensions for .NET, also known as Rx. Rx provides developers with a reactive programming model over the generic IObservable interface, as opposed to the traditional imperative programming model or the other reactive programming models that rely strictly on .NET Events or specific APIs.

A brief introduction

system.reactive refers to the Reactive Extensions (Rx), a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators. System.Reactive is the root namespace used through the library. Using Rx, developers represent asychronous data streams using LINQ operators, and parameterize the concurrency in the asynchronous data streams using Schedulers. Simply put, Rx = Observables + LINQ + Schedulers.

Whether you are authoring a traditional desktop or web-based application, you have to deal with asynchronous and event-based programming from time to time. Desktop applications have I/O operations and computationally expensive tasks that might take a long time to complete and potentially block other active threads. Furthermore, handling exceptions, cancellation, and synchronization is difficult and error-prone.

Using Rx, you can represent multiple asynchronous data streams (that come from diverse sources, e.g., stock quote, tweets, computer events, web service requests, etc., and subscribe to the event stream using the IObserver<T> interface. The IObservable<T> interface notifies the subscribed IObserver<T> interface whenever an event occurs.

Because observable sequences are data streams, you can query them using standard LINQ query operators implemented by the Observable extension methods. Thus you can filter, project, aggregate, compose and perform time-based operations on multiple events easily by using these standard LINQ operators. In addition, there are a number of other reactive stream specific operators that allow powerful queries to be written. Cancellation, exceptions, and synchronization are also handled gracefully by using the extension methods provided by Rx.

Rx complements and interoperates smoothly with both synchronous data streams (IEnumerable<T>) and single-value asynchronous computations (Task<T>).

Source and further information

The project is actively developed by Microsoft Open Technologies, Inc., in collaboration with a community of open source developers. The source code is hosted on github here.

Additional documentation, video, tutorials and hands-on-labs are available on MSDN, and help and discussions the Rx Forums.

ReactiveX has been ported to many platforms, and information about supported platforms and links to platform specific implementations can be found here.

Related tags

3422 questions
2
votes
1 answer

Recursion and Rx parallelism

While trying to traverse directory tree efficiently, I tried a RX solution described here. While this solution works for small tree depth, it's not useable for big tree depth. The Default Scheduler creates too many threads, slowing down the tree…
rducom
  • 7,072
  • 1
  • 25
  • 39
2
votes
2 answers

Can Reactive Extensions satisfy order invariance, synchronization and multithreading?

I want to be able process a stream of events on multiple cores, but keep everything synchronized so events are processed in lock step by all subscribers, so no single subscriber ever gets ahead of any other subscriber. In other words, I want a fast…
2
votes
2 answers

Observable not reacting to queue changed on different thread

I have the following code: static void Main() { var holderQueue = new ConcurrentQueue(GetInitialElements()); Action> addToQueueAction = AddToQueue; var observableQueue =…
Amc_rtty
  • 3,662
  • 11
  • 48
  • 73
2
votes
2 answers

Equivalent in RxJava

We can execute some code asynchronously in C# Rx, as shown below, using Observable.Start(). I am wondering what is the equivalent in RxJava. void Main() { AddTwoNumbersAsync (5,4) .Subscribe(x=>Console.WriteLine(x)); } IObservable
Aravind Yarram
  • 78,777
  • 46
  • 231
  • 327
2
votes
2 answers

Aggregate function before IObservable sequence is completed

Is there a way to use Aggregate function (Max, Count, ....) with Buffer before a sequence is completed. When Completed this will produce results, but with continues stream it does not give any results? I was expecting there is some way to make this…
user007
  • 1,122
  • 1
  • 10
  • 30
2
votes
1 answer

Observable.Delay or Observable.Buffer reusing same thread

Is there some version of Observable.Delay or Observable.Buffer that doesn't use a new thread for its timer? Perhaps with less precision.. I have a scenario where I need to call Observable.Delay on an observable that produces several thousands…
fsl
  • 831
  • 1
  • 11
  • 24
2
votes
1 answer

Reactive Extensions - polling observable - why won't it skip?

return Observable .Timer(TimeSpan.FromSeconds(2)) .SelectAsync(delegate { return this.getResponse(request); }) .Repeat() .Timeout(TimeSpan.FromSeconds(10), Observable.Return(new…
masonk
  • 9,176
  • 2
  • 47
  • 58
2
votes
1 answer

TestScheduler not working like expected on subscribed property (w throttle)

I'm pretty green with rx/ReactiveUi and want to write a xunit test using TestScheduler to check if the throttle for retrieving search suggestions is working properly. The idea is to use the TestScheudler for the timing, change the value for the…
road242
  • 2,492
  • 22
  • 30
2
votes
2 answers

combining one observable with latest from another observable

I'm trying to combine two observables whose values share some key. I want to produce a new value whenever the first observable produces a new value, combined with the latest value from a second observable which selection depends on the latest value…
fsl
  • 831
  • 1
  • 11
  • 24
2
votes
1 answer

Strange appearance of a null entry in the list of tasks

Here is the code involved: private static async Task DoRunInOrderAsync(SemaphoreSlim sem, IObservable taskSeedSource, CreateTaskDelegate createTask, OnTaskErrorDelegate onFailed,…
mark
  • 59,016
  • 79
  • 296
  • 580
2
votes
2 answers

Reactive Extensions for processing continuous streams of messages

I have a message processing application that currently operates on small messages that fit easily into memory. I am extending it to operate on messages larger than memory (in the 10s to 100s of gigabytes) which will require some kind of streaming…
Dan Hermann
  • 1,107
  • 1
  • 13
  • 27
2
votes
2 answers

Observable.FromEventPattern(addHandler, removeHandler ) - simplification?

When creating an observable from an event, it looks like the following is the most common way: var o = Observable.FromEventPattern(h => source.Event += h, h => source.Event -= h); I find this form a little…
Vegar
  • 12,828
  • 16
  • 85
  • 151
2
votes
1 answer

How to use async countdown event instead of collecting tasks and awaiting on them?

I have the following code: var tasks = await taskSeedSource .Select(taskSeed => GetPendingOrRunningTask(taskSeed, createTask, onFailed, onSuccess, sem)) .ToList() .ToTask(); if (tasks.Count == 0) { return; } if…
mark
  • 59,016
  • 79
  • 296
  • 580
2
votes
1 answer

What's the difference between source.StartWith(x).Replay(1) and source.Publish(x)

Given a sequence, IObservable source;, is there a difference between: var published = source.Publish(0); var publishedConnection = published.Connect(); and var replayed = source.StartWith(0).Replay(1); var replayedConnection =…
Philip C
  • 1,819
  • 28
  • 50
2
votes
1 answer

Subject that emits events to subscribers in specific order with back-pressure

Imagine a pipe of subscribers that you emit event to and it visits one subscriber after another. Having a PublishSubject and x subscribers/observables. Normally events are emitted to observers in a specific order but simultaneously regardless of…
lisak
  • 21,611
  • 40
  • 152
  • 243
1 2 3
99
100