namespace Terminal.Gui.App;
///
/// Manages timers.
///
public interface ITimedEvents
{
///
/// Adds a timeout to the application.
///
///
/// When the specified time passes, the callback will be invoked. If the callback returns , the
/// timeout will be
/// reset, repeating the invocation. If it returns , the timeout will stop and be removed. The
/// returned value is a
/// token that can be used to stop the timeout by calling .
///
object Add (TimeSpan time, Func callback);
///
object Add (Timeout timeout);
///
/// Invoked when a new timeout is added. To be used in the case when
/// is .
///
event EventHandler? Added;
///
/// Removes a previously scheduled timeout.
///
///
/// The token parameter is the value returned by or .
///
///
/// if the timeout is successfully removed; otherwise, .
/// This method also returns if the timeout is not found.
///
bool Remove (object token);
///
/// Runs all timeouts that are due.
///
void RunTimers ();
///
/// Returns the next planned execution time (key - UTC ticks)
/// for each timeout that is not actively executing.
///
SortedList Timeouts { get; }
///
/// Gets the timeout for the specified event.
///
/// The token of the event.
/// The for the event, or if the event is not found.
TimeSpan? GetTimeout (object token);
/// Stops and removes all timed events.
void StopAll ();
}