system.reactive

How do I create an IObservable<T> that returns a value every -n- seconds without skipping any

This below example was my attempt at doing this: var source = Observable.Sample( Observable.Range(1, int.MaxValue), TimeSpan.FromSeconds(2)); But when I .Subscribe() to that Observable and output it to the console, it shows a sequence like this, one line output every 2 seconds: OnNext: 312969 OnNext: 584486 OnNext: 8620...

Reactive Extensions for .NET (Rx): Take action once all events are completed

As a proof of concept, I want to write "Done" in a text box after a check box has been checked and a key has been pressed in a text box (in either order). I would expect this code to handle this, but it writes Done as soon as either event happens. Thanks for your help. var seq = Observable.FromEvent<EventArgs>(this.checkBox, "CheckedCha...

Are there any conventions on throwing exceptions from implementations of IObserver?

Hi! I'm implementing IObserver. Are there any conventions about throwing exceptions from IObserver? Can OnNext or any other method of my implementation throw exceptions? What should happen if exception is thrown in OnNext or OnCompleted - should I catch all exceptions and call this.OnError(ex)? What will happen if OnError throws? ...

Unit testing for an event using Reactive Extensions

I'm using Reactive Extensions for .NET (Rx) to expose events as IObservable<T>. I want to create an unit test where I assert that a particular event is fired. Here is a simplified version of the class I want to test: public sealed class ClassUnderTest : IDisposable { Subject<Unit> subject = new Subject<Unit>(); public IObservable<...

Problem combining Reactive Framework (Rx) queries to provide correct UI behaviour

I'm trying to remove the more tradition event handlers from a Silverlight application in favour of using a number of Rx queries to provide a better, easier to manage, behavioural abstraction. The problem that I need to solve, but can't quite crack it the way I want, is getting the behaviour of a search screen working. It's pretty standa...

Observable.Delay calling Dispose before OnNext is fired

I am having problem understanding how Observable.Delay works and when the Dispose() is meant to be called. Would anyone familiar with Rx be able to help please? The following code snippet: static void Main(string[] args) { var oneNumberEveryFiveSeconds = new SomeObservable(); // Instant echo oneNumberEve...

Enforcing Task Order using the .NET 4.0 Task Parallel Libraries

I have a program that has a ton of sensors producing data at a fairly high rate, and consumers that need to consume it. The consumers consume at very different rates. Since I am using IObserver/IObservable, the trivial solution was to simply create a Task for each event and wrap the OnNext() call and the data in a lamda. This worked v...