خرید بک لینک

Vote count: 0

I would like to have the Reactive Extension interval to fire every 1ms, but I realize that this is not true.

I did a simple experiment by creating 2 interval observable to check the total count in the 1ms interval.

  1. fire every 1 ms (add the counter)
  2. fire every 1 s (display and reset the counter)

In my debug console, I notice that the total counts in every 1s, is fluctuating (980 - 999), and I never able to get a constant count of 999.

int total = 0;
Observable.Interval(TimeSpan.FromMilliseconds(1))
    .Subscribe((e) =>
    {
        lock (this) {
            total++;
        }
    });

Observable.Interval(TimeSpan.FromSeconds(1))
    .Subscribe((x) =>
    {
        lock (this) {
            Debug.WriteLine(this.total);
            total = 0;
        }
    });

May I know how can I increase the precision of the interval?

asked 53 secs ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 7 خرداد 1395 ساعت: 12:41

صفحه بندی