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.Lock
    DistributedBackgroundService.ExecuteAsync(CancellationToken)
    BackgroundService.StartAsync(CancellationToken)
    BackgroundService.StopAsync(CancellationToken)
    BackgroundService.Dispose()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Silverback.Background
    Assembly: Silverback.Core.dll
    Syntax
    public abstract class RecurringDistributedBackgroundService : DistributedBackgroundService, IHostedService, IDisposable

    Constructors

    | Improve this doc View source

    RecurringDistributedBackgroundService(TimeSpan, DistributedLockSettings?, IDistributedLockManager, ISilverbackLogger<RecurringDistributedBackgroundService>)

    Initializes a new instance of the RecurringDistributedBackgroundService class.

    Declaration
    protected RecurringDistributedBackgroundService(TimeSpan interval, DistributedLockSettings? distributedLockSettings, IDistributedLockManager distributedLockManager, ISilverbackLogger<RecurringDistributedBackgroundService> logger)
    Parameters
    Type Name Description
    TimeSpan interval

    The TimeSpan interval between each execution.

    DistributedLockSettings distributedLockSettings

    Customizes the lock mechanism settings.

    IDistributedLockManager distributedLockManager

    The IDistributedLockManager.

    ISilverbackLogger<RecurringDistributedBackgroundService> logger

    The ISilverbackLogger.

    | Improve this doc View source

    RecurringDistributedBackgroundService(TimeSpan, IDistributedLockManager, ISilverbackLogger<RecurringDistributedBackgroundService>)

    Initializes a new instance of the RecurringDistributedBackgroundService class using the default settings for the lock mechanism.

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

    The interval between each execution.

    IDistributedLockManager distributedLockManager

    The IDistributedLockManager.

    ISilverbackLogger<RecurringDistributedBackgroundService> logger

    The ISilverbackLogger.

    Methods

    | Improve this doc View source

    ExecuteLockedAsync(CancellationToken)

    This method is called when the IHostedService starts and the lock is acquired. The implementation should return a task that represents the lifetime of the long running operation(s) being performed.

    Declaration
    protected override Task ExecuteLockedAsync(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 that represents the long running operations.

    Overrides
    DistributedBackgroundService.ExecuteLockedAsync(CancellationToken)
    | Improve this doc View source

    ExecuteRecurringAsync(CancellationToken)

    This method is called at regular intervals after the IHostedService starts and the lock is acquired. The implementation should return a task that represents the lifetime of the long running operation(s) being performed.

    Declaration
    protected abstract Task ExecuteRecurringAsync(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 that represents the long running operations.

    | Improve this doc View source

    Pause()

    Pauses the execution of the recurring task.

    Declaration
    public void Pause()
    | Improve this doc View source

    Resume()

    Resumes the execution of the previously paused recurring task.

    Declaration
    public void Resume()

    Implements

    IHostedService
    IDisposable
    • Improve this doc
    • View source
    GitHub E-Mail
    ↑ Back to top © 2020 Sergio Aquilini