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