Class SchedulerService
- Namespace
- Microsoft.Extensions.Hosting
- Assembly
- nanoFramework.Hosting.dll
Base class timer service which calls an asynchronous action after the configured interval.
public abstract class SchedulerService : IHostedService, IDisposable
- Inheritance
-
SchedulerService
- Implements
- Inherited Members
- Extension Methods
Constructors
SchedulerService(int, int, TimeSpan)
Schedules the execution of ExecuteAsync(CancellationToken) on the provided interval.
protected SchedulerService(int hour, int min, TimeSpan interval)
Parameters
hour
intThe hour the scheduler will start on.
min
intThe minute the scheduler will start on.
interval
TimeSpanThe TimeSpan interval scheduler will execute on.
SchedulerService(TimeSpan)
Schedules the immediate execution of ExecuteAsync(CancellationToken) on the provided interval.
protected SchedulerService(TimeSpan interval)
Parameters
Properties
Interval
Gets the interval of the timer.
protected TimeSpan Interval { get; }
Property Value
Time
Gets the due time of the timer.
protected TimeSpan Time { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
Releases the unmanaged resources used by the BackgroundService and optionally releases the managed resources.
protected virtual void Dispose(bool disposing)
Parameters
disposing
booltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
Remarks
If you override this method in a derived class, be sure to call the base class's Dispose(bool) method.
ExecuteAsync(CancellationToken)
This method is called each time the timer elapses.
protected abstract void ExecuteAsync(CancellationToken stoppingToken)
Parameters
stoppingToken
CancellationToken
ExecuteTimer()
Gets the Timer that executes the background operation.
public virtual Timer? ExecuteTimer()
Returns
Remarks
Will return null if the background operation hasn't started.
Finalize()
protected override void Finalize()
StartAsync(CancellationToken)
Triggered when the application host is ready to start the service.
public virtual void StartAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenIndicates that the start process has been aborted.
StopAsync(CancellationToken)
Triggered when the application host is performing a graceful shutdown.
public virtual void StopAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenIndicates that the shutdown process should no longer be graceful.