public static IObservable<long> CreateObservableTimerWithAction(this Action actionT, int timeSpan, Control control) { var obs = Observable.Create<long>( observer => { Observable.Interval(TimeSpan.FromMilliseconds(timeSpan)) .DistinctUntilChanged(fg =>control.Text ).Subscribe(l => actionT()); return Disposable.Empty; }); return obs; }
0r:
public static IObservable<long> CreateObservableTimer<T>(this Action actionT,int timeSpan) { var obs= Observable.Create<long>( observer => { Observable.Interval(TimeSpan.FromMilliseconds(timeSpan)) .DistinctUntilChanged().Subscribe(l => actionT()); return Disposable.Empty; }); return obs; }
I use this quite often so that temporary methods execute at a specific time until I destroy them (obs.Dispose ()).
CreateObservableTimer (() => CheckForDequeues (1), 500);
I actually sometimes use a long, but most of the time, and not ...
Even use this helper to check schedulers in the priority queue, so you can use it to
source share