I have a scenario where timer interval changes on every tick event. As shown in below code:
Timer tmrObj = new Timer();
tmrObj.Interval = TimeSpan.FromSeconds(11);
tmrObj.Tick += TimerTickHandler;
public void TimerTickHandler(EventArg arg)
{
tmrObj.pause();
var response = MakeSomeServiceCall();
tmr.Interval = response.Interval;
tmrObj.resume();
}
If I need to implement Timers in Rx for the same. I can achieve using Timer function. But how can I manipulate Interval on event tick as shown in the above code. The current timer interval implementation is as below:
var serviceCall = Observable.FromAsync<DataResponse>(MakeServiceCall);
var timerCall = Observable.Timer(TimeSpan.FromSeconds(100));
var response = from timer in timerCall
from reponse in serviceCall.TakeUntil(timerCall)
.Select(result => result);