ActionableProgress.cs 843 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma warning disable CS1591
  2. using System;
  3. namespace MediaBrowser.Common.Progress
  4. {
  5. /// <summary>
  6. /// Class ActionableProgress.
  7. /// </summary>
  8. /// <typeparam name="T">The type for the action parameter.</typeparam>
  9. public class ActionableProgress<T> : IProgress<T>
  10. {
  11. /// <summary>
  12. /// The _actions.
  13. /// </summary>
  14. private Action<T> _action;
  15. public event EventHandler<T> ProgressChanged;
  16. /// <summary>
  17. /// Registers the action.
  18. /// </summary>
  19. /// <param name="action">The action.</param>
  20. public void RegisterAction(Action<T> action)
  21. {
  22. _action = action;
  23. }
  24. public void Report(T value)
  25. {
  26. ProgressChanged?.Invoke(this, value);
  27. _action?.Invoke(value);
  28. }
  29. }
  30. }