I would like to know the purpose of such a request. Could you describe a use case a bit?
However, it looks like the following query might solve your problem. Initial forecasts are not needed if you already have some way of determining the origin of each value, but I have included them for generalization to fit your extremely abstract way of polling .; -)
Note. I assume someKeyThatVaries not shared data, as you showed it, so I also included the term anotherKeyThatVaries ; otherwise the whole request really doesn't make any sense to me.
var obs1 = Observable.Interval(TimeSpan.FromSeconds(1)) .Select(x => Tuple.Create(someKeyThatVaries, x)); var obs2 = Observable.Interval(TimeSpan.FromSeconds(.25)) .Select(x => Tuple.Create(anotherKeyThatVaries, x)); var results = obs1.Select(t => new { Key = t.Item1, Value = t.Item2, Kind = 1 }) .Merge( obs2.Select(t => new { Key = t.Item1, Value = t.Item2, Kind = 2 })) .GroupBy(t => t.Key, t => new { t.Value, t.Kind }) .SelectMany(g => g.Scan( new { X = -1L, Y = -1L, Yield = false }, (acc, cur) => cur.Kind == 1 ? new { X = cur.Value, Y = acc.Y, Yield = true } : new { X = acc.X, Y = cur.Value, Yield = false }) .Where(s => s.Yield) .Select(s => Tuple.Create(sX, sY)));
Dave sexton
source share