diff options
| author | Andrew Rabert <ar@nullsum.net> | 2018-12-27 18:27:57 -0500 |
|---|---|---|
| committer | Andrew Rabert <ar@nullsum.net> | 2018-12-27 18:27:57 -0500 |
| commit | a86b71899ec52c44ddc6c3018e8cc5e9d7ff4d62 (patch) | |
| tree | a74f6ea4a8abfa1664a605d31d48bc38245ccf58 /MediaBrowser.Common/Progress/ActionableProgress.cs | |
| parent | 9bac3ac616b01f67db98381feb09d34ebe821f9a (diff) | |
Add GPL modules
Diffstat (limited to 'MediaBrowser.Common/Progress/ActionableProgress.cs')
| -rw-r--r-- | MediaBrowser.Common/Progress/ActionableProgress.cs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/MediaBrowser.Common/Progress/ActionableProgress.cs b/MediaBrowser.Common/Progress/ActionableProgress.cs new file mode 100644 index 000000000..67347bc15 --- /dev/null +++ b/MediaBrowser.Common/Progress/ActionableProgress.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; + +namespace MediaBrowser.Common.Progress +{ + /// <summary> + /// Class ActionableProgress + /// </summary> + /// <typeparam name="T"></typeparam> + public class ActionableProgress<T> : IProgress<T> + { + /// <summary> + /// The _actions + /// </summary> + private Action<T> _action; + public event EventHandler<T> ProgressChanged; + + /// <summary> + /// Registers the action. + /// </summary> + /// <param name="action">The action.</param> + public void RegisterAction(Action<T> action) + { + _action = action; + } + + public void Report(T value) + { + if (ProgressChanged != null) + { + ProgressChanged(this, value); + } + + var action = _action; + if (action != null) + { + action(value); + } + } + } + + public class SimpleProgress<T> : IProgress<T> + { + public event EventHandler<T> ProgressChanged; + + public void Report(T value) + { + if (ProgressChanged != null) + { + ProgressChanged(this, value); + } + } + } +} |
