Show / Hide Table of Contents

    Class DistributedBackgroundService

    Extends the BackgroundService adding a distributed lock mechanism to prevent concurrent executions.

    Inheritance
    object
    BackgroundService
    DistributedBackgroundService
    RecurringDistributedBackgroundService
    Implements
    IHostedService
    IDisposable
    Inherited Members
    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 DistributedBackgroundService : BackgroundService, IHostedService, IDisposable

    Constructors

    | Improve this doc View source

    DistributedBackgroundService(DistributedLockSettings?, IDistributedLockManager, ISilverbackLogger<DistributedBackgroundService>)

    Initializes a new instance of the DistributedBackgroundService class.

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

    Customizes the lock mechanism settings.

    IDistributedLockManager distributedLockManager

    The IDistributedLockManager.

    ISilverbackLogger<DistributedBackgroundService> logger

    The ISilverbackLogger.

    | Improve this doc View source

    DistributedBackgroundService(IDistributedLockManager, ISilverbackLogger<DistributedBackgroundService>)

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

    Declaration
    protected DistributedBackgroundService(IDistributedLockManager distributedLockManager, ISilverbackLogger<DistributedBackgroundService> logger)
    Parameters
    Type Name Description
    IDistributedLockManager distributedLockManager

    The IDistributedLockManager.

    ISilverbackLogger<DistributedBackgroundService> logger

    The ISilverbackLogger.

    Properties

    | Improve this doc View source

    Lock

    Gets the acquired DistributedLock.

    Declaration
    protected DistributedLock? Lock { get; }
    Property Value
    Type Description
    DistributedLock

    Methods

    | Improve this doc View source

    ExecuteAsync(CancellationToken)

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

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

    Triggered when StopAsync(CancellationToken) is called.

    Returns
    Type Description
    Task

    A Task that represents the long running operations.

    Overrides
    BackgroundService.ExecuteAsync(CancellationToken)
    | 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 abstract 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.

    Implements

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