IScheduler.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
  2. namespace System.Reactive.Concurrency
  3. {
  4. /// <summary>
  5. /// Represents an object that schedules units of work.
  6. /// </summary>
  7. public interface IScheduler
  8. {
  9. /// <summary>
  10. /// Gets the scheduler's notion of current time.
  11. /// </summary>
  12. DateTimeOffset Now { get; }
  13. /// <summary>
  14. /// Schedules an action to be executed.
  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. IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action);
  21. /// <summary>
  22. /// Schedules an action to be executed after dueTime.
  23. /// </summary>
  24. /// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
  25. /// <param name="state">State passed to the action to be executed.</param>
  26. /// <param name="action">Action to be executed.</param>
  27. /// <param name="dueTime">Relative time after which to execute the action.</param>
  28. /// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
  29. IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action);
  30. /// <summary>
  31. /// Schedules an action to be executed at dueTime.
  32. /// </summary>
  33. /// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
  34. /// <param name="state">State passed to the action to be executed.</param>
  35. /// <param name="action">Action to be executed.</param>
  36. /// <param name="dueTime">Absolute time at which to execute the action.</param>
  37. /// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
  38. IDisposable Schedule<TState>(TState state, DateTimeOffset dueTime, Func<IScheduler, TState, IDisposable> action);
  39. }
  40. }