Exemplo n.º 1
0
        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));
            }
        }
Exemplo n.º 2
0
 public static Timer DelayedCallbackState(TimeSpan delay, TimerCallbackState call, object state)
 {
     return(new OneTimeTimerState(delay, call, state));
 }
Exemplo n.º 3
0
 public OneTimeTimerState(TimeSpan d, TimerCallbackState call, object state) : base(d)
 {
     m_Call  = call;
     m_State = state;
 }
Exemplo n.º 4
0
 public OneTimeTimerState( TimeSpan d, TimerCallbackState call, object state )
     : base(d)
 {
     m_Call = call;
     m_State = state;
 }
Exemplo n.º 5
0
 public static Timer DelayedCallbackState( TimeSpan delay, TimerCallbackState call, object state )
 {
     return new OneTimeTimerState( delay, call, state );
 }