public class Class1 { public IObservable<long> Timer; public IDisposable TimerSub; DateTime NextTime = new DateTime(0); public Class1() { this.NextTime = new DateTime(0); this.Timer = Observable.Timer(TimeSpan.FromSeconds(1)); this.TimerSub = this.Timer.Subscribe(x => DoWork()); } private void DoWork() { bool canWork = (this.NextTime.Ticks != 0); this.NextTime = this.CalculateFutureDate(); // change the timer interval to "this.NextTime - DateTime.Now" // how do I do this? if (canWork) { // Do some work stuff... } } private DateTime CalculateFutureDate() { return DateTime.Now.AddDays(1); } }
IObservable
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)