Timeout.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. namespace Terminal.Gui.App;
  2. /// <summary>
  3. /// Represents a scheduled timeout for use with timer management APIs.
  4. /// <para>
  5. /// Encapsulates a callback function to be invoked after a specified time interval. The callback can optionally
  6. /// indicate whether the timeout should repeat.
  7. /// </para>
  8. /// <para>
  9. /// Used by <see cref="ITimedEvents"/> and related timer systems to manage timed operations in the application.
  10. /// </para>
  11. /// </summary>
  12. public class Timeout
  13. {
  14. /// <summary>
  15. /// Gets or sets the function to invoke when the timeout expires.
  16. /// </summary>
  17. /// <value>
  18. /// A <see cref="Func{Boolean}"/> delegate. If the callback returns <see langword="true"/>, the timeout will be
  19. /// rescheduled and invoked again after the same interval.
  20. /// If the callback returns <see langword="false"/>, the timeout will be removed and not invoked again.
  21. /// </value>
  22. public Func<bool>? Callback { get; set; }
  23. /// <summary>
  24. /// Gets or sets the time interval to wait before invoking the <see cref="Callback"/>.
  25. /// </summary>
  26. /// <value>
  27. /// A <see cref="TimeSpan"/> representing the delay before the callback is invoked. If the timeout is rescheduled
  28. /// (i.e., <see cref="Callback"/> returns <see langword="true"/>), this interval is used again.
  29. /// </value>
  30. public virtual TimeSpan Span { get; set; }
  31. }