Search Results for

    Show / Hide Table of Contents
    View Source

    Class RecurringHostedServiceBase

    Provides a base class for recurring background tasks implemented as hosted services.

    Inheritance
    System.Object
    Namespace: Umbraco.Cms.Infrastructure.HostedServices
    Assembly: Umbraco.Infrastructure.dll
    Syntax
    public abstract class RecurringHostedServiceBase : IHostedService
    Remarks

    See: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-3.1&tabs=visual-studio#timed-background-tasks.

    Constructors

    View Source

    RecurringHostedServiceBase(Nullable<ILogger>, TimeSpan, TimeSpan)

    Initializes a new instance of the RecurringHostedServiceBase class.

    Declaration
    protected RecurringHostedServiceBase(ILogger? logger, TimeSpan period, TimeSpan delay)
    Parameters
    Type Name Description
    System.Nullable<ILogger> logger

    Logger.

    TimeSpan period

    Timespan representing how often the task should recur.

    TimeSpan delay

    Timespan representing the initial delay after application start-up before the first run of the task occurs.

    Fields

    View Source

    DefaultDelay

    The default delay to use for recurring tasks for the first run after application start-up if no alternative is configured.

    Declaration
    protected static readonly TimeSpan DefaultDelay
    Field Value
    Type Description
    TimeSpan

    Methods

    View Source

    ChangePeriod(TimeSpan)

    Change the period between operations.

    Declaration
    protected void ChangePeriod(TimeSpan newPeriod)
    Parameters
    Type Name Description
    TimeSpan newPeriod

    The new period between tasks

    View Source

    Dispose()

    Declaration
    public void Dispose()
    View Source

    Dispose(Boolean)

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing
    View Source

    ExecuteAsync(Object)

    Executes the task.

    Declaration
    public async void ExecuteAsync(object state)
    Parameters
    Type Name Description
    System.Object state

    The task state.

    View Source

    GetDelay(String, ICronTabParser, ILogger, TimeSpan)

    Determines the delay before the first run of a recurring task implemented as a hosted service when an optonal configuration for the first run time is available.

    Declaration
    protected static TimeSpan GetDelay(string firstRunTime, ICronTabParser cronTabParser, ILogger logger, TimeSpan defaultDelay)
    Parameters
    Type Name Description
    System.String firstRunTime

    The configured time to first run the task in crontab format.

    ICronTabParser cronTabParser

    An instance of ICronTabParser

    ILogger logger

    The logger.

    TimeSpan defaultDelay

    The default delay to use when a first run time is not configured.

    Returns
    Type Description
    TimeSpan

    The delay before first running the recurring task.

    View Source

    PerformExecuteAsync(Object)

    Declaration
    public abstract Task PerformExecuteAsync(object state)
    Parameters
    Type Name Description
    System.Object state
    Returns
    Type Description
    Task
    View Source

    StartAsync(CancellationToken)

    Declaration
    public Task StartAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    Task
    View Source

    StopAsync(CancellationToken)

    Declaration
    public Task StopAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    Task
    • Improve this Doc
    • View Source
    In This Article
    • Constructors
      • RecurringHostedServiceBase(Nullable<ILogger>, TimeSpan, TimeSpan)
    • Fields
      • DefaultDelay
    • Methods
      • ChangePeriod(TimeSpan)
      • Dispose()
      • Dispose(Boolean)
      • ExecuteAsync(Object)
      • GetDelay(String, ICronTabParser, ILogger, TimeSpan)
      • PerformExecuteAsync(Object)
      • StartAsync(CancellationToken)
      • StopAsync(CancellationToken)
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX