1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-23 16:32:48 +00:00
Radarr/NzbDrone.Core/WebTimer.cs

38 lines
1 KiB
C#
Raw Normal View History

using System;
using System.Web;
using System.Web.Caching;
using NLog;
using NzbDrone.Core.Providers.Jobs;
namespace NzbDrone.Core
{
class WebTimer
{
private readonly JobProvider _jobProvider;
private static CacheItemRemovedCallback _onCacheRemove;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public WebTimer(JobProvider jobProvider)
{
_jobProvider = jobProvider;
}
public void StartTimer(int secondInterval)
{
_onCacheRemove = new CacheItemRemovedCallback(DoWork);
HttpRuntime.Cache.Insert(GetType().ToString(), secondInterval, null,
DateTime.Now.AddSeconds(secondInterval), Cache.NoSlidingExpiration,
CacheItemPriority.NotRemovable, _onCacheRemove);
}
public void DoWork(string k, object v, CacheItemRemovedReason r)
{
2011-08-03 16:29:03 +00:00
_jobProvider.QueueScheduled();
StartTimer(Convert.ToInt32(v));
}
}
}