aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations/ScheduledTasks
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-10-25 11:48:44 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-10-25 11:48:44 -0400
commit492f897f818abc1a1eee0352864ce4c06de4de1c (patch)
tree1a6c269e398f91c5d2f9930d1686591ed0301c74 /MediaBrowser.Common.Implementations/ScheduledTasks
parent9babddb2715b1fcc4a40043d7d9bddfeb958be20 (diff)
3.0.5768.6
Diffstat (limited to 'MediaBrowser.Common.Implementations/ScheduledTasks')
-rw-r--r--MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs6
-rw-r--r--MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs25
2 files changed, 29 insertions, 2 deletions
diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
index 52612c4c11..95f29915db 100644
--- a/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
+++ b/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
@@ -13,7 +13,6 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
-using MediaBrowser.Common.IO;
namespace MediaBrowser.Common.Implementations.ScheduledTasks
{
@@ -304,6 +303,11 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
}
}
+ public void ReloadTriggerEvents()
+ {
+ ReloadTriggerEvents(false);
+ }
+
/// <summary>
/// Reloads the trigger events.
/// </summary>
diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs
index 6c72441aa8..845c984fb7 100644
--- a/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs
+++ b/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs
@@ -12,6 +12,7 @@ using System.Linq;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Common.IO;
+using Microsoft.Win32;
namespace MediaBrowser.Common.Implementations.ScheduledTasks
{
@@ -69,6 +70,28 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
_fileSystem = fileSystem;
ScheduledTasks = new IScheduledTaskWorker[] { };
+
+ BindToSystemEvent();
+ }
+
+ private void BindToSystemEvent()
+ {
+ try
+ {
+ SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
+ }
+ catch
+ {
+
+ }
+ }
+
+ void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
+ {
+ foreach (var task in ScheduledTasks)
+ {
+ task.ReloadTriggerEvents();
+ }
}
/// <summary>
@@ -127,7 +150,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
{
QueueScheduledTask<T>(new TaskExecutionOptions());
}
-
+
/// <summary>
/// Queues the scheduled task.
/// </summary>