public PeriodicallyScheduledWorkItem(CatchSchedulerPeriodic scheduler, TState state, TimeSpan period, Func <TState, TState> action) { _catchScheduler = scheduler; _action = action; Disposable.SetSingle(ref _cancel, scheduler._scheduler.SchedulePeriodic((@this: this, state), period, tuple => tuple.@this?.Tick(tuple.state) ?? default)); }
public PeriodicallyScheduledWorkItem(CatchSchedulerPeriodic scheduler, TState state, TimeSpan period, Func <TState, TState> action) { _catchScheduler = scheduler; _action = action; // Note that avoiding closure allocation here would introduce infinite generic recursion over the TState argument Disposable.SetSingle(ref _cancel, scheduler._scheduler.SchedulePeriodic(state, period, state1 => Tick(state1).state)); }
protected override bool TryGetService(IServiceProvider provider, Type serviceType, out object service) { service = provider.GetService(serviceType); if (service != null) { if (serviceType == typeof(ISchedulerLongRunning)) { service = new CatchSchedulerLongRunning((ISchedulerLongRunning)service, _handler); } else if (serviceType == typeof(ISchedulerPeriodic)) { service = new CatchSchedulerPeriodic((ISchedulerPeriodic)service, _handler); } } return(true); }