I have a ValueChanged event.
I want to subscribe to it using Rx only when Value > 5 followed by Value < -5 and both were fired within 5 seconds.
I have managed to create an observable that works with the Value condition.
How can I check if they were fired within 5 seconds?
Here’s my code:
IObservable<MyEventArgs> data = Observable.FromEventPattern<...
var up = data.Where(ev => ev.Value > 0.5).Take(1);
var down = data.SkipUntil(up).Where(ev => ev.Value < -0.5).Take(1);
down.Subscribe(ar => { Console.WriteLine("OK"); });
[edit]:
Here is an image representing my input data and when the expected result should occure

[edit]:
On more thing:
Why I want this? 😉
I’m trying to use WP7 accelerometer to detect up/down move that occurred within ‘n’ seconds and caused at least 0,5G (up) and less than -0,5G (down)
Thanks,
Bartek
Based on “up” and “down” assigned as above, how about the following code:
I have not tested this yet, but maybe it is worth to try this.