jellyfin/MediaBrowser.Common/Progress/ActionableProgress.cs

37 lines
843 B
C#
Raw Normal View History

#pragma warning disable CS1591
using System;
2018-12-27 16:27:57 -07:00
namespace MediaBrowser.Common.Progress
{
/// <summary>
/// Class ActionableProgress.
2018-12-27 16:27:57 -07:00
/// </summary>
/// <typeparam name="T">The type for the action parameter.</typeparam>
2018-12-27 16:27:57 -07:00
public class ActionableProgress<T> : IProgress<T>
{
/// <summary>
/// The _actions.
2018-12-27 16:27:57 -07:00
/// </summary>
private Action<T> _action;
2018-12-27 16:27:57 -07:00
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)
{
ProgressChanged?.Invoke(this, value);
2018-12-27 16:27:57 -07:00
_action?.Invoke(value);
2018-12-27 16:27:57 -07:00
}
}
}