jellyfin/MediaBrowser.Common/ScheduledTasks/StartupTrigger.cs

49 lines
1.2 KiB
C#
Raw Normal View History

2013-02-24 14:53:54 -07:00
using System;
using System.Threading.Tasks;
2013-02-20 18:33:05 -07:00
namespace MediaBrowser.Common.ScheduledTasks
{
/// <summary>
/// Class StartupTaskTrigger
/// </summary>
2013-02-24 14:53:54 -07:00
public class StartupTrigger : ITaskTrigger
2013-02-20 18:33:05 -07:00
{
/// <summary>
/// Stars waiting for the trigger action
/// </summary>
2013-02-23 00:57:11 -07:00
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
2013-02-24 14:53:54 -07:00
public async void Start(bool isApplicationStartup)
2013-02-20 18:33:05 -07:00
{
2013-02-23 00:57:11 -07:00
if (isApplicationStartup)
{
await Task.Delay(2000).ConfigureAwait(false);
2013-02-20 18:33:05 -07:00
2013-02-23 00:57:11 -07:00
OnTriggered();
}
2013-02-20 18:33:05 -07:00
}
/// <summary>
/// Stops waiting for the trigger action
/// </summary>
2013-02-24 14:53:54 -07:00
public void Stop()
2013-02-20 18:33:05 -07:00
{
}
2013-02-24 14:53:54 -07:00
/// <summary>
/// Occurs when [triggered].
/// </summary>
public event EventHandler<EventArgs> Triggered;
/// <summary>
/// Called when [triggered].
/// </summary>
private void OnTriggered()
{
if (Triggered != null)
{
Triggered(this, EventArgs.Empty);
}
}
2013-02-20 18:33:05 -07:00
}
}