Class RecurringDistributedBackgroundService
- Namespace
- Silverback.Background
- Assembly
- Silverback.Core.dll
Extends the DistributedBackgroundService calling the execute method at regular intervals. The distributed lock mechanism prevents concurrent executions.
public abstract class RecurringDistributedBackgroundService : DistributedBackgroundService, IHostedService, IDisposable
- Inheritance
-
RecurringDistributedBackgroundService
- Implements
- Derived
- Inherited Members
Constructors
RecurringDistributedBackgroundService(TimeSpan, IDistributedLock, ISilverbackLogger<RecurringDistributedBackgroundService>)
Initializes a new instance of the RecurringDistributedBackgroundService class.
protected RecurringDistributedBackgroundService(TimeSpan interval, IDistributedLock distributedLock, ISilverbackLogger<RecurringDistributedBackgroundService> logger)
Parameters
intervalTimeSpanThe TimeSpan interval between each execution.
distributedLockIDistributedLockThe IDistributedLock.
loggerISilverbackLogger<RecurringDistributedBackgroundService>The ISilverbackLogger.
Methods
AcquireLockAndExecuteAsync(CancellationToken)
Acquires the lock and calls the ExecuteLockedAsync(CancellationToken) method to perform the operation(s).
protected override Task AcquireLockAndExecuteAsync(CancellationToken stoppingToken)
Parameters
stoppingTokenCancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
Pause()
Pauses the execution of the recurring task.
public void Pause()
Resume()
Resumes the execution of the previously paused recurring task.
public void Resume()