2013-03-05 06:51:07 +01:00
|
|
|
|
using System.Timers;
|
2013-04-10 02:47:04 +02:00
|
|
|
|
using NzbDrone.Common.Eventing;
|
2013-03-05 06:51:07 +01:00
|
|
|
|
using NzbDrone.Core.Lifecycle;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Jobs
|
|
|
|
|
{
|
2013-04-10 02:47:04 +02:00
|
|
|
|
public class JobTimer : IHandle<ApplicationStartedEvent>
|
2013-03-05 06:51:07 +01:00
|
|
|
|
{
|
|
|
|
|
private readonly IJobController _jobController;
|
|
|
|
|
private readonly Timer _timer;
|
|
|
|
|
|
|
|
|
|
public JobTimer(IJobController jobController)
|
|
|
|
|
{
|
|
|
|
|
_jobController = jobController;
|
|
|
|
|
_timer = new Timer();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-10 02:47:04 +02:00
|
|
|
|
public void Handle(ApplicationStartedEvent message)
|
2013-03-05 06:51:07 +01:00
|
|
|
|
{
|
|
|
|
|
_timer.Interval = 1000 * 30;
|
|
|
|
|
_timer.Elapsed += (o, args) => _jobController.EnqueueScheduled();
|
|
|
|
|
_timer.Start();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|