/// <summary> /// Creates a timer that executes the specified <paramref name="callback"/> /// once after the delay specified by <paramref name="millisecondsDelay"/>. /// </summary> /// <param name="console">The used <see cref="SmartConsole"/>.</param> /// <param name="callback">The action to invoke on each timer tick.</param> /// <param name="millisecondsDelay">The number of milliseconds to wait /// before calling the callback.</param> /// <param name="name">The name of the associated timer. Useful when /// calling <see cref="ClearTimeout(SmartConsole, string)"/>.</param> /// <returns>A reference to the current <see cref="SmartConsole" /> instance.</returns> public static SmartConsole SetTimeout(this SmartConsole console, Action <TimerEventArgs> callback, double millisecondsDelay, string name = null) { TimerManager.Add(console, callback, millisecondsDelay, name, repeat: false); return(console); }
/// <summary> /// Creates a timer that executes the specified <paramref name="callback"/> /// at a regular interval specified by <paramref name="millisecondsInterval"/>. /// </summary> /// <param name="console">The used <see cref="SmartConsole"/>.</param> /// <param name="callback">The action to invoke on each timer tick.</param> /// <param name="millisecondsInterval">The number of milliseconds that /// should elapse between two consecutive ticks.</param> /// <param name="name">The name of the associated timer. Useful when /// calling <see cref="ClearInterval(SmartConsole, string)"/>.</param> /// <returns>A reference to the current <see cref="SmartConsole" /> instance.</returns> public static SmartConsole SetInterval(this SmartConsole console, Action <TimerEventArgs> callback, double millisecondsInterval, string name = null) { TimerManager.Add(console, callback, millisecondsInterval, name, repeat: true); return(console); }