1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/NzbDrone.Core/Jobs/JobTimer.cs

33 lines
839 B
C#
Raw Normal View History

using System.Timers;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Lifecycle;
namespace NzbDrone.Core.Jobs
{
2013-04-19 07:46:18 +03:00
public class JobTimer :
IHandle<ApplicationStartedEvent>,
IHandle<ApplicationShutdownRequested>
{
private readonly IJobController _jobController;
private readonly Timer _timer;
public JobTimer(IJobController jobController)
{
_jobController = jobController;
_timer = new Timer();
}
public void Handle(ApplicationStartedEvent message)
{
_timer.Interval = 1000 * 30;
_timer.Elapsed += (o, args) => _jobController.EnqueueScheduled();
_timer.Start();
}
2013-04-19 07:46:18 +03:00
public void Handle(ApplicationShutdownRequested message)
{
_timer.Stop();
}
}
}