Show / Hide Table of Contents

    Class RecurringDistributedBackgroundService

    Extends the DistributedBackgroundService calling the execute method at regular intervals. The distributed lock mechanism prevents concurrent executions.

    Inheritance
    object
    BackgroundService
    DistributedBackgroundService
    RecurringDistributedBackgroundService
    OutboxWorkerService
    Implements
    IHostedService
    IDisposable
    Inherited Members
    DistributedBackgroundService.ExecuteAsync(CancellationToken)
    DistributedBackgroundService.ExecuteLockedAsync(CancellationToken)
    DistributedBackgroundService.DistributedLock
    BackgroundService.StartAsync(CancellationToken)
    BackgroundService.StopAsync(CancellationToken)
    BackgroundService.Dispose()
    BackgroundService.ExecuteTask
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: Silverback.Background
    Assembly: Silverback.Core.dll
    Syntax
    public abstract class RecurringDistributedBackgroundService : DistributedBackgroundService, IHostedService, IDisposable

    Constructors

    RecurringDistributedBackgroundService(TimeSpan, IDistributedLock, ISilverbackLogger<RecurringDistributedBackgroundService>)

    Initializes a new instance of the RecurringDistributedBackgroundService class.

    Declaration
    protected RecurringDistributedBackgroundService(TimeSpan interval, IDistributedLock distributedLock, ISilverbackLogger<RecurringDistributedBackgroundService> logger)
    Parameters
    Type Name Description
    TimeSpan interval

    The TimeSpan interval between each execution.

    IDistributedLock distributedLock

    The IDistributedLock.

    ISilverbackLogger<RecurringDistributedBackgroundService> logger

    The ISilverbackLogger.

    Methods

    AcquireLockAndExecuteAsync(CancellationToken)

    Acquires the lock and calls the ExecuteLockedAsync(CancellationToken) method to perform the operation(s).

    Declaration
    protected override Task AcquireLockAndExecuteAsync(CancellationToken stoppingToken)
    Parameters
    Type Name Description
    CancellationToken stoppingToken

    A CancellationToken to observe while waiting for the task to complete.

    Returns
    Type Description
    Task

    A Task representing the asynchronous operation.

    Overrides
    DistributedBackgroundService.AcquireLockAndExecuteAsync(CancellationToken)

    Pause()

    Pauses the execution of the recurring task.

    Declaration
    public void Pause()

    Resume()

    Resumes the execution of the previously paused recurring task.

    Declaration
    public void Resume()

    Implements

    IHostedService
    IDisposable
    GitHub E-Mail
    ↑ Back to top © 2026 Sergio Aquilini