I try to access a stream every 2 seconds and get the first value within this time. Example:
Values: -1--2-3---4-----5--6-7--8 Result: -1-------3--------5------ I tried the code like int this thread (quite similar problem):
subject.AsObservable().Window(TimeSpan.FromSeconds(2)) .SelectMany(f => f.Take(1)) .Subscribe(f => { Console.WriteLine("Counter: " + counter + " Time:" + DateTime.Now.Millisecond); counter++; }); However, the 2 seconds do not work, the counter updates too fast even after 200 milliseconds.
What am I missing?
Data are added to the subject by using this code:
Task.Run(async () => { while (await call.ResponseStream.MoveNext(default(CancellationToken))) { foreach (var result in call.ResponseStream.Current.Results) { subject.OnNext(result); } } });
DateTime.Now.Millisecond?