ISchedulerLongRunning.cs 1.3 KB

12345678910111213141516171819202122232425262728
  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 starting long-running tasks.
  9. /// This type of scheduler can be used to run loops more efficiently instead of using recursive scheduling.
  10. /// </summary>
  11. public interface ISchedulerLongRunning
  12. {
  13. /// <summary>
  14. /// Schedules a long-running piece of work.
  15. /// </summary>
  16. /// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
  17. /// <param name="state">State passed to the action to be executed.</param>
  18. /// <param name="action">Action to be executed.</param>
  19. /// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
  20. /// <remarks>
  21. /// <para><b>Notes to implementers</b></para>
  22. /// The returned disposable object should not prevent the work from starting, but only set the cancellation flag passed to the specified action.
  23. /// </remarks>
  24. IDisposable ScheduleLongRunning<TState>(TState state, Action<TState, ICancelable> action);
  25. }
  26. }