From 1e5c3db9eba730fe8b52995e5c699c22983fa62a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 23 Jun 2017 12:04:45 -0400 Subject: support individual library refreshing --- MediaBrowser.Common/Progress/ActionableProgress.cs | 46 +++++++++++++--------- 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'MediaBrowser.Common/Progress') diff --git a/MediaBrowser.Common/Progress/ActionableProgress.cs b/MediaBrowser.Common/Progress/ActionableProgress.cs index 39f46ce057..503f3f407a 100644 --- a/MediaBrowser.Common/Progress/ActionableProgress.cs +++ b/MediaBrowser.Common/Progress/ActionableProgress.cs @@ -7,12 +7,13 @@ namespace MediaBrowser.Common.Progress /// Class ActionableProgress /// /// - public class ActionableProgress : Progress, IDisposable + public class ActionableProgress : IProgress, IDisposable { /// /// The _actions /// private readonly List> _actions = new List>(); + public event EventHandler ProgressChanged; /// /// Registers the action. @@ -21,22 +22,6 @@ namespace MediaBrowser.Common.Progress public void RegisterAction(Action action) { _actions.Add(action); - - ProgressChanged -= ActionableProgress_ProgressChanged; - ProgressChanged += ActionableProgress_ProgressChanged; - } - - /// - /// Actionables the progress_ progress changed. - /// - /// The sender. - /// The e. - void ActionableProgress_ProgressChanged(object sender, T e) - { - foreach (var action in _actions) - { - action(e); - } } /// @@ -55,9 +40,34 @@ namespace MediaBrowser.Common.Progress { if (disposing) { - ProgressChanged -= ActionableProgress_ProgressChanged; _actions.Clear(); } } + + public void Report(T value) + { + if (ProgressChanged != null) + { + ProgressChanged(this, value); + } + + foreach (var action in _actions) + { + action(value); + } + } + } + + public class SimpleProgress : IProgress + { + public event EventHandler ProgressChanged; + + public void Report(T value) + { + if (ProgressChanged != null) + { + ProgressChanged(this, value); + } + } } } -- cgit v1.2.3