2013-02-24 22:53:54 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
2013-02-21 02:33:05 +01:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Common.ScheduledTasks
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class StartupTaskTrigger
|
|
|
|
|
/// </summary>
|
2013-02-24 22:53:54 +01:00
|
|
|
|
public class StartupTrigger : ITaskTrigger
|
2013-02-21 02:33:05 +01:00
|
|
|
|
{
|
2014-08-12 01:41:11 +02:00
|
|
|
|
public int DelayMs { get; set; }
|
|
|
|
|
|
|
|
|
|
public StartupTrigger()
|
|
|
|
|
{
|
|
|
|
|
DelayMs = 3000;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-21 02:33:05 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Stars waiting for the trigger action
|
|
|
|
|
/// </summary>
|
2013-02-23 08:57:11 +01:00
|
|
|
|
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
|
2013-02-24 22:53:54 +01:00
|
|
|
|
public async void Start(bool isApplicationStartup)
|
2013-02-21 02:33:05 +01:00
|
|
|
|
{
|
2013-02-23 08:57:11 +01:00
|
|
|
|
if (isApplicationStartup)
|
|
|
|
|
{
|
2014-08-12 01:41:11 +02:00
|
|
|
|
await Task.Delay(DelayMs).ConfigureAwait(false);
|
2013-02-21 02:33:05 +01:00
|
|
|
|
|
2013-02-23 08:57:11 +01:00
|
|
|
|
OnTriggered();
|
|
|
|
|
}
|
2013-02-21 02:33:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Stops waiting for the trigger action
|
|
|
|
|
/// </summary>
|
2013-02-24 22:53:54 +01:00
|
|
|
|
public void Stop()
|
2013-02-21 02:33:05 +01:00
|
|
|
|
{
|
|
|
|
|
}
|
2013-02-24 22:53:54 +01: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-21 02:33:05 +01:00
|
|
|
|
}
|
|
|
|
|
}
|