public async Task StartAsync(CancellationToken cancellationToken) { _logger.Information("Init timed host service"); await Initialise(cancellationToken); foreach (var item in _services) { _logger.Information("Timed Background Service {Name} is starting.", item.Command.Name); Type command = item.Command; var callbackState = new TimerCallbackState(command: command, cancellationToken: cancellationToken, item.Period, 0); _timers.Add(command.Name, new Timer(async(state) => await timerCallback(state), callbackState, TimeSpan.FromSeconds(1), item.Period)); } }
public static Timer DelayedCallbackState(TimeSpan delay, TimerCallbackState call, object state) { return(new OneTimeTimerState(delay, call, state)); }
public OneTimeTimerState(TimeSpan d, TimerCallbackState call, object state) : base(d) { m_Call = call; m_State = state; }
public OneTimeTimerState( TimeSpan d, TimerCallbackState call, object state ) : base(d) { m_Call = call; m_State = state; }
public static Timer DelayedCallbackState( TimeSpan delay, TimerCallbackState call, object state ) { return new OneTimeTimerState( delay, call, state ); }