예제 #1
0
        public static IObservable <TSource> SetMaxFrequency <TSource>(this IObservable <TSource> source, double maxFrequency)
        {
            var filter = new FrequencyFilter(maxFrequency);

            return(ChainNext <TSource, TSource>(source, obs => o => { if (filter.CheckLap())
                                                                      {
                                                                          obs.OnNext(o);
                                                                      }
                                                }));
        }
예제 #2
0
        public void ctor_2()
        {
            var filter = new FrequencyFilter(25);

            Observable2.Interval(TimeSpan.FromMilliseconds(20))
            .Do(_ => filter.CheckLap())
            .Select(_ => filter.ArrangedFrequency)
            .Subscribe(Console.WriteLine);

            Thread.Sleep(3000);
        }
예제 #3
0
        public void ctor_1()
        {
            var filter = new FrequencyFilter(25);
            var meter  = new FrequencyMeter();

            Observable2.Interval(TimeSpan.FromMilliseconds(20))
            .Where(_ => filter.CheckLap())
            .Do(_ => meter.RecordLap())
            .Subscribe(Console.WriteLine);

            Thread.Sleep(3000);
            Assert.IsTrue(meter.Frequency > 24);
            Assert.IsTrue(meter.Frequency <= 25);
        }