using MediaBrowser.Common.Kernel;
using System;
using System.Threading.Tasks;
namespace MediaBrowser.Common.ScheduledTasks
{
///
/// Class StartupTaskTrigger
///
public class StartupTrigger : BaseTaskTrigger
{
///
/// Gets the kernel.
///
/// The kernel.
protected IKernel Kernel { get; private set; }
///
/// Initializes a new instance of the class.
///
/// The kernel.
public StartupTrigger(IKernel kernel)
{
Kernel = kernel;
}
///
/// Stars waiting for the trigger action
///
protected internal override void Start()
{
Kernel.ReloadCompleted += Kernel_ReloadCompleted;
}
async void Kernel_ReloadCompleted(object sender, EventArgs e)
{
await Task.Delay(2000).ConfigureAwait(false);
OnTriggered();
}
///
/// Stops waiting for the trigger action
///
protected internal override void Stop()
{
Kernel.ReloadCompleted -= Kernel_ReloadCompleted;
}
}
}