public IPoller <T> Create(IPollerSettings settings, Func <T> getCurrentState, IScheduler scheduler = null) { if (scheduler == null) { scheduler = TaskPoolScheduler.Default; } return(new Poller <T>(settings, getCurrentState, scheduler)); }
public Poller(IPollerSettings settings, Func <T> getCurrentState, IScheduler scheduler) { if (settings == null) { throw new ArgumentNullException(); } if (getCurrentState == null) { throw new ArgumentNullException(); } Settings = settings; GetCurrentState = getCurrentState; State = Observable.Interval(Settings.Period, scheduler).Select(_ => GetCurrentState.Invoke()); }