ISchedulerPeriodic.cs 1.2 KB

12345678910111213141516171819202122232425
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Reactive.Disposables;
  5. namespace System.Reactive.Concurrency
  6. {
  7. /// <summary>
  8. /// Scheduler with support for running periodic tasks.
  9. /// This type of scheduler can be used to run timers more efficiently instead of using recursive scheduling.
  10. /// </summary>
  11. public interface ISchedulerPeriodic
  12. {
  13. /// <summary>
  14. /// Schedules a periodic piece of work.
  15. /// </summary>
  16. /// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
  17. /// <param name="state">Initial state passed to the action upon the first iteration.</param>
  18. /// <param name="period">Period for running the work periodically.</param>
  19. /// <param name="action">Action to be executed, potentially updating the state.</param>
  20. /// <returns>The disposable object used to cancel the scheduled recurring action (best effort).</returns>
  21. IDisposable SchedulePeriodic<TState>(TState state, TimeSpan period, Func<TState, TState> action);
  22. }
  23. }