#nullable disable #pragma warning disable CS1591 using System; using System.Threading.Tasks; using MediaBrowser.Model.Tasks; using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.ScheduledTasks { /// /// Class StartupTaskTrigger. /// public class StartupTrigger : ITaskTrigger { /// /// Occurs when [triggered]. /// public event EventHandler Triggered; public int DelayMs { get; set; } /// /// Gets or sets the options of this task. /// public TaskOptions TaskOptions { get; set; } public StartupTrigger() { DelayMs = 3000; } /// /// Stars waiting for the trigger action. /// /// The last result. /// The logger. /// The name of the task. /// if set to true [is application startup]. public async void Start(TaskResult lastResult, ILogger logger, string taskName, bool isApplicationStartup) { if (isApplicationStartup) { await Task.Delay(DelayMs).ConfigureAwait(false); OnTriggered(); } } /// /// Stops waiting for the trigger action. /// public void Stop() { } /// /// Called when [triggered]. /// private void OnTriggered() { Triggered?.Invoke(this, EventArgs.Empty); } } }