[ This question is regarding IObservable / Rx ]
var frequency = TimeSpan.FromMinutes(5);
Result.Delay(frequency).Subscribe(i => Debug.WriteLine("After Fixed Delay"));
Result.Delay(GetAsymptotingTime()).Subscribe(i => Debug.WriteLine("After Changing Delay"));
While the code for variable delay compiles it gets called only once, providing only the first value (essentially a fixed value).
Looks like there is a new overload of .Delay that allows this functionality within RX itself:
From http://blogs.msdn.com/b/rxteam/archive/2012/03/12/reactive-extensions-v2-0-beta-available-now.aspx :
var res = input.Delay(x => Observable.Timer(TimeSpan.FromSeconds(x.Length)));
Given the user input, it gets delays for a duration equal to the length of the input in seconds. Stated otherwise, the delay of each element can now be dependent on the data itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With